Skip to content

Commit 5453a4f

Browse files
committed
FileCheck bool_compare.
1 parent f0690d5 commit 5453a4f

13 files changed

+191
-103
lines changed

tests/mir-opt/bool_compare.rs

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/mir-opt/equal_true.opt.InstSimplify.diff

Lines changed: 0 additions & 36 deletions
This file was deleted.

tests/mir-opt/equal_true.rs

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/mir-opt/bool_compare.opt3.InstSimplify.diff renamed to tests/mir-opt/instsimplify/bool_compare.eq_false.InstSimplify.diff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
- // MIR for `opt3` before InstSimplify
2-
+ // MIR for `opt3` after InstSimplify
1+
- // MIR for `eq_false` before InstSimplify
2+
+ // MIR for `eq_false` after InstSimplify
33

4-
fn opt3(_1: bool) -> u32 {
4+
fn eq_false(_1: bool) -> u32 {
55
debug x => _1;
66
let mut _0: u32;
77
let mut _2: bool;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
- // MIR for `eq_true` before InstSimplify
2+
+ // MIR for `eq_true` after InstSimplify
3+
4+
fn eq_true(_1: bool) -> u32 {
5+
debug x => _1;
6+
let mut _0: u32;
7+
let mut _2: bool;
8+
let mut _3: bool;
9+
10+
bb0: {
11+
StorageLive(_2);
12+
StorageLive(_3);
13+
_3 = _1;
14+
- _2 = Eq(move _3, const true);
15+
+ _2 = move _3;
16+
switchInt(move _2) -> [0: bb2, otherwise: bb1];
17+
}
18+
19+
bb1: {
20+
StorageDead(_3);
21+
_0 = const 0_u32;
22+
goto -> bb3;
23+
}
24+
25+
bb2: {
26+
StorageDead(_3);
27+
_0 = const 1_u32;
28+
goto -> bb3;
29+
}
30+
31+
bb3: {
32+
StorageDead(_2);
33+
return;
34+
}
35+
}
36+

tests/mir-opt/bool_compare.opt4.InstSimplify.diff renamed to tests/mir-opt/instsimplify/bool_compare.false_eq.InstSimplify.diff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
- // MIR for `opt4` before InstSimplify
2-
+ // MIR for `opt4` after InstSimplify
1+
- // MIR for `false_eq` before InstSimplify
2+
+ // MIR for `false_eq` after InstSimplify
33

4-
fn opt4(_1: bool) -> u32 {
4+
fn false_eq(_1: bool) -> u32 {
55
debug x => _1;
66
let mut _0: u32;
77
let mut _2: bool;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
- // MIR for `false_ne` before InstSimplify
2+
+ // MIR for `false_ne` after InstSimplify
3+
4+
fn false_ne(_1: bool) -> u32 {
5+
debug x => _1;
6+
let mut _0: u32;
7+
let mut _2: bool;
8+
let mut _3: bool;
9+
10+
bb0: {
11+
StorageLive(_2);
12+
StorageLive(_3);
13+
_3 = _1;
14+
- _2 = Ne(const false, move _3);
15+
+ _2 = move _3;
16+
switchInt(move _2) -> [0: bb2, otherwise: bb1];
17+
}
18+
19+
bb1: {
20+
StorageDead(_3);
21+
_0 = const 0_u32;
22+
goto -> bb3;
23+
}
24+
25+
bb2: {
26+
StorageDead(_3);
27+
_0 = const 1_u32;
28+
goto -> bb3;
29+
}
30+
31+
bb3: {
32+
StorageDead(_2);
33+
return;
34+
}
35+
}
36+

tests/mir-opt/not_equal_false.opt.InstSimplify.diff renamed to tests/mir-opt/instsimplify/bool_compare.ne_false.InstSimplify.diff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
- // MIR for `opt` before InstSimplify
2-
+ // MIR for `opt` after InstSimplify
1+
- // MIR for `ne_false` before InstSimplify
2+
+ // MIR for `ne_false` after InstSimplify
33

4-
fn opt(_1: bool) -> u32 {
4+
fn ne_false(_1: bool) -> u32 {
55
debug x => _1;
66
let mut _0: u32;
77
let mut _2: bool;

tests/mir-opt/bool_compare.opt1.InstSimplify.diff renamed to tests/mir-opt/instsimplify/bool_compare.ne_true.InstSimplify.diff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
- // MIR for `opt1` before InstSimplify
2-
+ // MIR for `opt1` after InstSimplify
1+
- // MIR for `ne_true` before InstSimplify
2+
+ // MIR for `ne_true` after InstSimplify
33

4-
fn opt1(_1: bool) -> u32 {
4+
fn ne_true(_1: bool) -> u32 {
55
debug x => _1;
66
let mut _0: u32;
77
let mut _2: bool;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// unit-test: InstSimplify
2+
3+
// EMIT_MIR bool_compare.eq_true.InstSimplify.diff
4+
fn eq_true(x: bool) -> u32 {
5+
// CHECK-LABEL: fn eq_true(
6+
// CHECK-NOT: Eq(
7+
if x == true { 0 } else { 1 }
8+
}
9+
10+
// EMIT_MIR bool_compare.true_eq.InstSimplify.diff
11+
fn true_eq(x: bool) -> u32 {
12+
// CHECK-LABEL: fn true_eq(
13+
// CHECK-NOT: Eq(
14+
if true == x { 0 } else { 1 }
15+
}
16+
17+
// EMIT_MIR bool_compare.ne_true.InstSimplify.diff
18+
fn ne_true(x: bool) -> u32 {
19+
// CHECK-LABEL: fn ne_true(
20+
// CHECK: Not(
21+
if x != true { 0 } else { 1 }
22+
}
23+
24+
// EMIT_MIR bool_compare.true_ne.InstSimplify.diff
25+
fn true_ne(x: bool) -> u32 {
26+
// CHECK-LABEL: fn true_ne(
27+
// CHECK: Not(
28+
if true != x { 0 } else { 1 }
29+
}
30+
31+
// EMIT_MIR bool_compare.eq_false.InstSimplify.diff
32+
fn eq_false(x: bool) -> u32 {
33+
// CHECK-LABEL: fn eq_false(
34+
// CHECK: Not(
35+
if x == false { 0 } else { 1 }
36+
}
37+
38+
// EMIT_MIR bool_compare.false_eq.InstSimplify.diff
39+
fn false_eq(x: bool) -> u32 {
40+
// CHECK-LABEL: fn false_eq(
41+
// CHECK: Not(
42+
if false == x { 0 } else { 1 }
43+
}
44+
45+
// EMIT_MIR bool_compare.ne_false.InstSimplify.diff
46+
fn ne_false(x: bool) -> u32 {
47+
// CHECK-LABEL: fn ne_false(
48+
// CHECK-NOT: Ne(
49+
if x != false { 0 } else { 1 }
50+
}
51+
52+
// EMIT_MIR bool_compare.false_ne.InstSimplify.diff
53+
fn false_ne(x: bool) -> u32 {
54+
// CHECK-LABEL: fn false_ne(
55+
// CHECK-NOT: Ne(
56+
if false != x { 0 } else { 1 }
57+
}
58+
59+
fn main() {
60+
eq_true(false);
61+
true_eq(false);
62+
ne_true(false);
63+
true_ne(false);
64+
eq_false(false);
65+
false_eq(false);
66+
ne_false(false);
67+
false_ne(false);
68+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
- // MIR for `true_eq` before InstSimplify
2+
+ // MIR for `true_eq` after InstSimplify
3+
4+
fn true_eq(_1: bool) -> u32 {
5+
debug x => _1;
6+
let mut _0: u32;
7+
let mut _2: bool;
8+
let mut _3: bool;
9+
10+
bb0: {
11+
StorageLive(_2);
12+
StorageLive(_3);
13+
_3 = _1;
14+
- _2 = Eq(const true, move _3);
15+
+ _2 = move _3;
16+
switchInt(move _2) -> [0: bb2, otherwise: bb1];
17+
}
18+
19+
bb1: {
20+
StorageDead(_3);
21+
_0 = const 0_u32;
22+
goto -> bb3;
23+
}
24+
25+
bb2: {
26+
StorageDead(_3);
27+
_0 = const 1_u32;
28+
goto -> bb3;
29+
}
30+
31+
bb3: {
32+
StorageDead(_2);
33+
return;
34+
}
35+
}
36+

tests/mir-opt/bool_compare.opt2.InstSimplify.diff renamed to tests/mir-opt/instsimplify/bool_compare.true_ne.InstSimplify.diff

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
- // MIR for `opt2` before InstSimplify
2-
+ // MIR for `opt2` after InstSimplify
1+
- // MIR for `true_ne` before InstSimplify
2+
+ // MIR for `true_ne` after InstSimplify
33

4-
fn opt2(_1: bool) -> u32 {
4+
fn true_ne(_1: bool) -> u32 {
55
debug x => _1;
66
let mut _0: u32;
77
let mut _2: bool;

tests/mir-opt/not_equal_false.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)