diff --git a/tests/mir-opt/bool_compare.rs b/tests/mir-opt/bool_compare.rs deleted file mode 100644 index 3de3fb93d15..00000000000 --- a/tests/mir-opt/bool_compare.rs +++ /dev/null @@ -1,29 +0,0 @@ -// skip-filecheck -// unit-test: InstSimplify - -// EMIT_MIR bool_compare.opt1.InstSimplify.diff -fn opt1(x: bool) -> u32 { - if x != true { 0 } else { 1 } -} - -// EMIT_MIR bool_compare.opt2.InstSimplify.diff -fn opt2(x: bool) -> u32 { - if true != x { 0 } else { 1 } -} - -// EMIT_MIR bool_compare.opt3.InstSimplify.diff -fn opt3(x: bool) -> u32 { - if x == false { 0 } else { 1 } -} - -// EMIT_MIR bool_compare.opt4.InstSimplify.diff -fn opt4(x: bool) -> u32 { - if false == x { 0 } else { 1 } -} - -fn main() { - opt1(false); - opt2(false); - opt3(false); - opt4(false); -} diff --git a/tests/mir-opt/equal_true.opt.InstSimplify.diff b/tests/mir-opt/equal_true.opt.InstSimplify.diff deleted file mode 100644 index 88a51000c93..00000000000 --- a/tests/mir-opt/equal_true.opt.InstSimplify.diff +++ /dev/null @@ -1,36 +0,0 @@ -- // MIR for `opt` before InstSimplify -+ // MIR for `opt` after InstSimplify - - fn opt(_1: bool) -> i32 { - debug x => _1; - let mut _0: i32; - let mut _2: bool; - let mut _3: bool; - - bb0: { - StorageLive(_2); - StorageLive(_3); - _3 = _1; -- _2 = Eq(move _3, const true); -+ _2 = move _3; - switchInt(move _2) -> [0: bb2, otherwise: bb1]; - } - - bb1: { - StorageDead(_3); - _0 = const 0_i32; - goto -> bb3; - } - - bb2: { - StorageDead(_3); - _0 = const 1_i32; - goto -> bb3; - } - - bb3: { - StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/equal_true.rs b/tests/mir-opt/equal_true.rs deleted file mode 100644 index 8d7cfe73ffc..00000000000 --- a/tests/mir-opt/equal_true.rs +++ /dev/null @@ -1,12 +0,0 @@ -// skip-filecheck -// unit-test InstSimplify - -// EMIT_MIR equal_true.opt.InstSimplify.diff - -fn opt(x: bool) -> i32 { - if x == true { 0 } else { 1 } -} - -fn main() { - opt(true); -} diff --git a/tests/mir-opt/bool_compare.opt3.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify.diff similarity index 83% rename from tests/mir-opt/bool_compare.opt3.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify.diff index 034d5e44013..5c09963d433 100644 --- a/tests/mir-opt/bool_compare.opt3.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt3` before InstSimplify -+ // MIR for `opt3` after InstSimplify +- // MIR for `eq_false` before InstSimplify ++ // MIR for `eq_false` after InstSimplify - fn opt3(_1: bool) -> u32 { + fn eq_false(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify.diff new file mode 100644 index 00000000000..a80133b0eb0 --- /dev/null +++ b/tests/mir-opt/instsimplify/bool_compare.eq_true.InstSimplify.diff @@ -0,0 +1,36 @@ +- // MIR for `eq_true` before InstSimplify ++ // MIR for `eq_true` after InstSimplify + + fn eq_true(_1: bool) -> u32 { + debug x => _1; + let mut _0: u32; + let mut _2: bool; + let mut _3: bool; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; +- _2 = Eq(move _3, const true); ++ _2 = move _3; + switchInt(move _2) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + StorageDead(_3); + _0 = const 0_u32; + goto -> bb3; + } + + bb2: { + StorageDead(_3); + _0 = const 1_u32; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/bool_compare.opt4.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify.diff similarity index 83% rename from tests/mir-opt/bool_compare.opt4.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify.diff index d3096da6c5a..8235d5263bb 100644 --- a/tests/mir-opt/bool_compare.opt4.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt4` before InstSimplify -+ // MIR for `opt4` after InstSimplify +- // MIR for `false_eq` before InstSimplify ++ // MIR for `false_eq` after InstSimplify - fn opt4(_1: bool) -> u32 { + fn false_eq(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify.diff new file mode 100644 index 00000000000..77d076c6c14 --- /dev/null +++ b/tests/mir-opt/instsimplify/bool_compare.false_ne.InstSimplify.diff @@ -0,0 +1,36 @@ +- // MIR for `false_ne` before InstSimplify ++ // MIR for `false_ne` after InstSimplify + + fn false_ne(_1: bool) -> u32 { + debug x => _1; + let mut _0: u32; + let mut _2: bool; + let mut _3: bool; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; +- _2 = Ne(const false, move _3); ++ _2 = move _3; + switchInt(move _2) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + StorageDead(_3); + _0 = const 0_u32; + goto -> bb3; + } + + bb2: { + StorageDead(_3); + _0 = const 1_u32; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/not_equal_false.opt.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify.diff similarity index 83% rename from tests/mir-opt/not_equal_false.opt.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify.diff index 1342966aa15..2362b11297e 100644 --- a/tests/mir-opt/not_equal_false.opt.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt` before InstSimplify -+ // MIR for `opt` after InstSimplify +- // MIR for `ne_false` before InstSimplify ++ // MIR for `ne_false` after InstSimplify - fn opt(_1: bool) -> u32 { + fn ne_false(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/bool_compare.opt1.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify.diff similarity index 83% rename from tests/mir-opt/bool_compare.opt1.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify.diff index 657c11516a1..6ccbd2fb7a1 100644 --- a/tests/mir-opt/bool_compare.opt1.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt1` before InstSimplify -+ // MIR for `opt1` after InstSimplify +- // MIR for `ne_true` before InstSimplify ++ // MIR for `ne_true` after InstSimplify - fn opt1(_1: bool) -> u32 { + fn ne_true(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/instsimplify/bool_compare.rs b/tests/mir-opt/instsimplify/bool_compare.rs new file mode 100644 index 00000000000..77f427b0d7c --- /dev/null +++ b/tests/mir-opt/instsimplify/bool_compare.rs @@ -0,0 +1,68 @@ +// unit-test: InstSimplify + +// EMIT_MIR bool_compare.eq_true.InstSimplify.diff +fn eq_true(x: bool) -> u32 { + // CHECK-LABEL: fn eq_true( + // CHECK-NOT: Eq( + if x == true { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.true_eq.InstSimplify.diff +fn true_eq(x: bool) -> u32 { + // CHECK-LABEL: fn true_eq( + // CHECK-NOT: Eq( + if true == x { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.ne_true.InstSimplify.diff +fn ne_true(x: bool) -> u32 { + // CHECK-LABEL: fn ne_true( + // CHECK: Not( + if x != true { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.true_ne.InstSimplify.diff +fn true_ne(x: bool) -> u32 { + // CHECK-LABEL: fn true_ne( + // CHECK: Not( + if true != x { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.eq_false.InstSimplify.diff +fn eq_false(x: bool) -> u32 { + // CHECK-LABEL: fn eq_false( + // CHECK: Not( + if x == false { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.false_eq.InstSimplify.diff +fn false_eq(x: bool) -> u32 { + // CHECK-LABEL: fn false_eq( + // CHECK: Not( + if false == x { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.ne_false.InstSimplify.diff +fn ne_false(x: bool) -> u32 { + // CHECK-LABEL: fn ne_false( + // CHECK-NOT: Ne( + if x != false { 0 } else { 1 } +} + +// EMIT_MIR bool_compare.false_ne.InstSimplify.diff +fn false_ne(x: bool) -> u32 { + // CHECK-LABEL: fn false_ne( + // CHECK-NOT: Ne( + if false != x { 0 } else { 1 } +} + +fn main() { + eq_true(false); + true_eq(false); + ne_true(false); + true_ne(false); + eq_false(false); + false_eq(false); + ne_false(false); + false_ne(false); +} diff --git a/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify.diff new file mode 100644 index 00000000000..18675329a2e --- /dev/null +++ b/tests/mir-opt/instsimplify/bool_compare.true_eq.InstSimplify.diff @@ -0,0 +1,36 @@ +- // MIR for `true_eq` before InstSimplify ++ // MIR for `true_eq` after InstSimplify + + fn true_eq(_1: bool) -> u32 { + debug x => _1; + let mut _0: u32; + let mut _2: bool; + let mut _3: bool; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = _1; +- _2 = Eq(const true, move _3); ++ _2 = move _3; + switchInt(move _2) -> [0: bb2, otherwise: bb1]; + } + + bb1: { + StorageDead(_3); + _0 = const 0_u32; + goto -> bb3; + } + + bb2: { + StorageDead(_3); + _0 = const 1_u32; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/bool_compare.opt2.InstSimplify.diff b/tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify.diff similarity index 83% rename from tests/mir-opt/bool_compare.opt2.InstSimplify.diff rename to tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify.diff index bc8be62bd49..dc91cf8a5c4 100644 --- a/tests/mir-opt/bool_compare.opt2.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify.diff @@ -1,7 +1,7 @@ -- // MIR for `opt2` before InstSimplify -+ // MIR for `opt2` after InstSimplify +- // MIR for `true_ne` before InstSimplify ++ // MIR for `true_ne` after InstSimplify - fn opt2(_1: bool) -> u32 { + fn true_ne(_1: bool) -> u32 { debug x => _1; let mut _0: u32; let mut _2: bool; diff --git a/tests/mir-opt/not_equal_false.rs b/tests/mir-opt/not_equal_false.rs deleted file mode 100644 index 8008df79ceb..00000000000 --- a/tests/mir-opt/not_equal_false.rs +++ /dev/null @@ -1,11 +0,0 @@ -// skip-filecheck -// unit-test: InstSimplify -// EMIT_MIR not_equal_false.opt.InstSimplify.diff - -fn opt(x: bool) -> u32 { - if x != false { 0 } else { 1 } -} - -fn main() { - opt(false); -}