rust/compiler/rustc_codegen_ssa
Stuart Cook 44ffe1023c
Rollup merge of #144764 - scottmcm:tweak-impossible-discriminant-assume, r=WaffleLapkin
[codegen] assume the tag, not the relative discriminant

Address the issue mentioned in <https://github.com/llvm/llvm-project/issues/134024#issuecomment-3131782555> by changing discriminant calculation to `assume` on the originally-loaded `tag`, rather than on `cast(tag)-OFFSET`.

The previous way does make the *purpose* of the assume clearer, IMHO, since you see `assume(x != 4); if p { x } else { 4 }`, but doing it this way instead means that the `add`s optimize away in LLVM21, which is more important.  And this new way is still easily thought of as being like metadata on the load saying specifically which value is impossible.

Demo of the LLVM20 vs LLVM21 difference: <https://llvm.godbolt.org/z/n54x5Mq1T>

r? ``@nikic``
2025-08-08 12:52:50 +10:00
..
src Rollup merge of #144764 - scottmcm:tweak-impossible-discriminant-assume, r=WaffleLapkin 2025-08-08 12:52:50 +10:00
Cargo.toml remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
messages.ftl Move LTO symbol export calculation from backends to cg_ssa 2025-07-21 07:58:44 +00:00
README.md mv compiler to compiler/ 2020-08-30 18:45:07 +03:00

Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.