FileCheck bool_compare.
This commit is contained in:
parent
f0690d5232
commit
5453a4f056
@ -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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -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;
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
@ -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;
|
68
tests/mir-opt/instsimplify/bool_compare.rs
Normal file
68
tests/mir-opt/instsimplify/bool_compare.rs
Normal file
@ -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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
@ -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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user