rust/tests/mir-opt/if_condition_int.dont_remove_comparison.SimplifyComparisonIntegral.diff
dianqk 37f83fb11d
Use Copy in the SwitchInt terminator
Move can be used only when both the compared operand and the operand on switch are move operands.
This commit directly changes to Copy, because I don't know if Move has beneficial.
2026-01-12 18:16:39 +08:00

54 lines
1.3 KiB
Diff

- // MIR for `dont_remove_comparison` before SimplifyComparisonIntegral
+ // MIR for `dont_remove_comparison` after SimplifyComparisonIntegral
fn dont_remove_comparison(_1: i8) -> i32 {
debug a => _1;
let mut _0: i32;
let _2: bool;
let mut _3: i8;
let mut _4: i32;
let mut _5: bool;
let mut _6: i32;
let mut _7: bool;
scope 1 {
debug b => _2;
}
bb0: {
nop;
StorageLive(_3);
_3 = copy _1;
_2 = Eq(copy _1, const 17_i8);
StorageDead(_3);
- switchInt(copy _2) -> [0: bb2, otherwise: bb1];
+ switchInt(copy _1) -> [17: bb1, otherwise: bb2];
}
bb1: {
StorageLive(_6);
StorageLive(_7);
_7 = copy _2;
_6 = copy _2 as i32 (IntToInt);
StorageDead(_7);
_0 = Add(const 100_i32, move _6);
StorageDead(_6);
goto -> bb3;
}
bb2: {
StorageLive(_4);
StorageLive(_5);
_5 = copy _2;
_4 = copy _2 as i32 (IntToInt);
StorageDead(_5);
_0 = Add(const 10_i32, move _4);
StorageDead(_4);
goto -> bb3;
}
bb3: {
nop;
return;
}
}