bors 158c309513 Auto merge of #110197 - cjgillot:codegen-discr, r=pnkfelix
Do not attempt to commute comparison and cast to codegen discriminants

The general algorithm to compute a discriminant is:
```
relative_tag = tag - niche_start
is_niche = relative_tag <= (ule) relative_max
discr = if is_niche {
    cast(relative_tag) + niche_variants.start()
} else {
    untagged_variant
}
```

We have an optimization branch which attempts to merge the addition and the subtraction by commuting them with the cast. We currently get this optimization wrong.

This PR takes the easiest and safest way: remove the optimization, and let LLVM handle it. (Perf may not agree with that course of action 😅)

There may be a less invasive solution, but I don't have the necessary knowledge of LLVM semantics to find it. Cranelift has the same optimization, which should be handled similarly.
cc `@nikic` and `@bjorn3` if you have a better solution.

Fixes https://github.com/rust-lang/rust/issues/110128
2023-04-14 21:54:56 +00:00
..
2023-04-03 09:24:11 +02:00
2023-04-14 00:06:21 +12:00
2023-04-03 09:24:07 +02:00
2023-04-03 09:24:11 +02:00
2023-04-03 15:59:21 +00:00
2023-04-11 17:45:42 +00:00
2023-04-03 09:24:11 +02:00
2023-04-07 18:07:11 +10:00
2023-04-14 16:26:11 +00:00
2023-04-05 01:01:45 +09:00
2023-04-13 23:39:14 +12:00
2023-04-03 15:59:21 +00:00
2023-04-07 09:11:53 +02:00
2023-04-03 15:59:21 +00:00
2023-04-03 15:59:21 +00:00
2023-04-11 10:27:57 +02:00
2023-04-03 09:24:11 +02:00
2023-03-22 15:15:41 -07:00
2023-04-13 22:10:26 -05:00
2023-03-29 18:04:44 -04:00
2023-04-05 15:59:29 +00:00
2023-04-13 22:10:26 -05:00
2023-04-13 22:10:26 -05:00