2024-04-20 06:19:34 -05:00
|
|
|
//@ test-mir-pass: GVN
|
2019-09-14 23:05:19 -05:00
|
|
|
|
2020-06-08 07:14:45 -05:00
|
|
|
// FIXME(wesleywiser): Ideally, we could const-prop away all of this and just be left with
|
|
|
|
// `let x = 42` but that doesn't work because const-prop doesn't support `Operand::Indirect`
|
|
|
|
// and `InterpCx::eval_place()` always forces an allocation which creates the `Indirect`.
|
|
|
|
// Fixing either of those will allow us to const-prop this away.
|
|
|
|
|
2020-04-04 15:25:54 -05:00
|
|
|
// EMIT_MIR_FOR_EACH_BIT_WIDTH
|
2023-09-20 16:43:33 -05:00
|
|
|
// EMIT_MIR discriminant.main.GVN.diff
|
2019-09-14 23:05:19 -05:00
|
|
|
fn main() {
|
2023-12-02 14:28:33 -06:00
|
|
|
// CHECK-LABEL: fn main(
|
|
|
|
// CHECK: bb0: {
|
|
|
|
// CHECK: switchInt(const 1_isize) -> [1: bb1, otherwise: bb3];
|
|
|
|
// CHECK: bb1: {
|
|
|
|
// CHECK: switchInt(const true) -> [0: bb3, otherwise: bb2];
|
|
|
|
// CHECK: bb2: {
|
|
|
|
// CHECK: [[tmp:_.*]] = const 42_i32;
|
|
|
|
// CHECK: goto -> bb4;
|
|
|
|
// CHECK: bb3: {
|
|
|
|
// CHECK: [[tmp]] = const 10_i32;
|
|
|
|
// CHECK: goto -> bb4;
|
|
|
|
// CHECK: bb4: {
|
|
|
|
// CHECK: {{_.*}} = Add(move [[tmp]], const 0_i32);
|
2019-09-14 23:05:19 -05:00
|
|
|
let x = (if let Some(true) = Some(true) { 42 } else { 10 }) + 0;
|
|
|
|
}
|