rust/tests/codegen/intrinsics
bors 3b022d8cee Auto merge of #133852 - x17jiri:cold_path, r=saethlin
improve cold_path()

#120370 added a new instrinsic `cold_path()` and used it to fix `likely` and `unlikely`

However, in order to limit scope, the information about cold code paths is only used in 2-target switch instructions. This is sufficient for `likely` and `unlikely`, but limits usefulness of `cold_path` for idiomatic rust. For example, code like this:

```
if let Some(x) = y { ... }
```

may generate 3-target switch:

```
switch y.discriminator:
0 => true branch
1 = > false branch
_ => unreachable
```

and therefore marking a branch as cold will have no effect.

This PR improves `cold_path()` to work with arbitrary switch instructions.

Note that for 2-target switches, we can use `llvm.expect`, but for multiple targets we need to manually emit branch weights. I checked Clang and it also emits weights in this situation. The Clang's weight calculation is more complex that this PR, which I believe is mainly because `switch` in `C/C++` can have multiple cases going to the same target.
2025-02-18 07:49:09 +00:00
..
aggregate-thin-pointer.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
carrying_mul_add.rs Update carrying_mul_add test to tolerate nuw 2025-01-03 20:25:14 +00:00
cold_path2.rs improve cold_path() 2025-02-17 06:39:58 +01:00
cold_path3.rs improve cold_path() 2025-02-17 06:39:58 +01:00
cold_path.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
compare_bytes.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
const_eval_select.rs Run rustfmt on tests/codegen/. 2024-05-31 15:56:43 +10:00
ctlz.rs Add codegen tests for changed intrinsics 2024-04-16 12:35:22 +00:00
ctpop.rs Add codegen tests for changed intrinsics 2024-04-16 12:35:22 +00:00
disjoint_bitor.rs Handle the case where the or disjoint folds immediately to a constant 2025-02-02 21:04:10 -08:00
exact_div.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
likely_assert.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
likely.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
mask.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
nearby.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
nontemporal.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
offset_from.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00
offset.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
prefetch.rs Run rustfmt on tests/codegen/. 2024-05-31 15:56:43 +10:00
ptr_metadata.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
rotate_left.rs Add codegen tests for changed intrinsics 2024-04-16 12:35:22 +00:00
rustc_intrinsic_must_be_overridden.rs Don't generate functions with the rustc_intrinsic_must_be_overridden attribute 2024-08-19 06:26:52 +08:00
select_unpredictable.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
three_way_compare.rs Set signext or zeroext for integer arguments on RISC-V 2024-10-23 04:42:03 +02:00
transmute-niched.rs transmute should also assume non-null pointers 2025-02-12 23:01:27 -08:00
transmute-x64.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
transmute.rs transmute should also assume non-null pointers 2025-02-12 23:01:27 -08:00
typed_swap.rs rename typed_swap → typed_swap_nonoverlapping 2024-12-25 10:53:03 +01:00
unchecked_math.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
unlikely.rs tests/codegen: use -Copt-level=3 instead of -O 2025-02-11 13:41:35 -08:00
volatile_order.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
volatile.rs [AUTO_GENERATED] Migrate compiletest to use ui_test-style //@ directives 2024-02-22 16:04:04 +00:00