Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9c91a4e

Browse files
Failing diff test
1 parent 360f7d7 commit 9c91a4e

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
- // MIR for `bitwise_not` before JumpThreading
2+
+ // MIR for `bitwise_not` after JumpThreading
3+
4+
fn bitwise_not() -> i32 {
5+
let mut _0: i32;
6+
let mut _1: i32;
7+
let mut _2: bool;
8+
let mut _3: i32;
9+
let mut _4: i32;
10+
scope 1 {
11+
debug a => _1;
12+
}
13+
14+
bb0: {
15+
StorageLive(_1);
16+
_1 = const 0_i32;
17+
_1 = const 1_i32;
18+
StorageLive(_2);
19+
StorageLive(_3);
20+
StorageLive(_4);
21+
_4 = copy _1;
22+
_3 = Not(move _4);
23+
StorageDead(_4);
24+
_2 = Eq(move _3, const 0_i32);
25+
- switchInt(move _2) -> [0: bb2, otherwise: bb1];
26+
+ goto -> bb1;
27+
}
28+
29+
bb1: {
30+
StorageDead(_3);
31+
_0 = const 1_i32;
32+
goto -> bb3;
33+
}
34+
35+
bb2: {
36+
StorageDead(_3);
37+
_0 = const 0_i32;
38+
goto -> bb3;
39+
}
40+
41+
bb3: {
42+
StorageDead(_2);
43+
StorageDead(_1);
44+
return;
45+
}
46+
}
47+

‎tests/mir-opt/jump_threading.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,16 @@ fn floats() -> u32 {
531531
if x == 0.0 { 0 } else { 1 }
532532
}
533533

534+
pub fn bitwise_not() -> i32 {
535+
// CHECK-LABEL: fn bitwise_not(
536+
// CHECK: switchInt(
537+
538+
// Test for #131195, which was optimizing `!a == b` into `a != b`.
539+
let mut a: i32 = 0;
540+
a = 1;
541+
if !a == 0 { 1 } else { 0 }
542+
}
543+
534544
fn main() {
535545
// CHECK-LABEL: fn main(
536546
too_complex(Ok(0));
@@ -562,3 +572,4 @@ fn main() {
562572
// EMIT_MIR jump_threading.assume.JumpThreading.diff
563573
// EMIT_MIR jump_threading.aggregate_copy.JumpThreading.diff
564574
// EMIT_MIR jump_threading.floats.JumpThreading.diff
575+
// EMIT_MIR jump_threading.bitwise_not.JumpThreading.diff

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /