rust/compiler/rustc_codegen_ssa/src
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
..
back update flags for consistency 2025-08-02 21:07:46 +05:00
debuginfo Flatten ifs in rustc_codegen_ssa 2025-03-17 18:56:52 +00:00
mir [codegen] assume the tag, not the relative discriminant 2025-08-06 09:11:35 -07:00
traits Revert "Preserve the .debug_gdb_scripts section" 2025-08-06 18:01:07 +00:00
assert_module_sources.rs Move methods from Map to TyCtxt, part 4. 2025-03-12 08:55:37 +11:00
base.rs Revert "Preserve the .debug_gdb_scripts section" 2025-08-06 18:01:07 +00:00
codegen_attrs.rs remove rustc_attr_data_structures 2025-07-31 14:19:27 +02:00
common.rs Remove useless lifetime parameter. 2025-07-23 23:54:37 +00:00
errors.rs Move LTO symbol export calculation from backends to cg_ssa 2025-07-21 07:58:44 +00:00
lib.rs [Arm64EC] Only decorate functions with # 2025-06-23 12:38:35 -07:00
meth.rs Eliminate all direct uses of LLVMMDStringInContext2 2025-07-14 08:27:08 +00:00
mono_item.rs use codegen_instance_attrs where an instance is (easily) available 2025-07-16 23:24:32 +02:00
size_of_val.rs Replace some Option<Span> with Span and use DUMMY_SP instead of None 2025-06-05 14:14:59 +00:00
target_features.rs Rollup merge of #138689 - jedbrown:jed/nvptx-target-feature, r=ZuseZ4 2025-08-07 20:49:36 +10:00