Chandler Carruth | f156f0c | 2011-11-26 08:24:25 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -simplifycfg -S | FileCheck %s |
Chris Lattner | 62f565d | 2005-09-23 18:43:57 +0000 | [diff] [blame] | 2 | |
Tanya Lattner | baa370b | 2008-03-18 03:45:45 +0000 | [diff] [blame] | 3 | define void @test(i32* %P, i32* %Q, i1 %A, i1 %B) { |
Chandler Carruth | f156f0c | 2011-11-26 08:24:25 +0000 | [diff] [blame] | 4 | ; CHECK: test |
| 5 | ; CHECK: br i1 |
| 6 | ; CHECK-NOT: br i1 |
| 7 | ; CHECK: ret |
| 8 | ; CHECK: ret |
| 9 | |
| 10 | entry: |
Tanya Lattner | baa370b | 2008-03-18 03:45:45 +0000 | [diff] [blame] | 11 | br i1 %A, label %a, label %b |
Chandler Carruth | f156f0c | 2011-11-26 08:24:25 +0000 | [diff] [blame] | 12 | a: |
Tanya Lattner | baa370b | 2008-03-18 03:45:45 +0000 | [diff] [blame] | 13 | br i1 %B, label %b, label %c |
Chandler Carruth | f156f0c | 2011-11-26 08:24:25 +0000 | [diff] [blame] | 14 | b: |
Tanya Lattner | baa370b | 2008-03-18 03:45:45 +0000 | [diff] [blame] | 15 | store i32 123, i32* %P |
| 16 | ret void |
Chandler Carruth | f156f0c | 2011-11-26 08:24:25 +0000 | [diff] [blame] | 17 | c: |
Tanya Lattner | baa370b | 2008-03-18 03:45:45 +0000 | [diff] [blame] | 18 | ret void |
Chris Lattner | 62f565d | 2005-09-23 18:43:57 +0000 | [diff] [blame] | 19 | } |
Manman Ren | d33f4ef | 2012-06-13 05:43:29 +0000 | [diff] [blame] | 20 | |
| 21 | ; rdar://10554090 |
| 22 | define zeroext i1 @test2(i64 %i0, i64 %i1) nounwind uwtable readonly ssp { |
| 23 | entry: |
| 24 | ; CHECK: test2 |
| 25 | ; CHECK: br i1 |
| 26 | %and.i.i = and i64 %i0, 281474976710655 |
| 27 | %and.i11.i = and i64 %i1, 281474976710655 |
| 28 | %or.cond = icmp eq i64 %and.i.i, %and.i11.i |
| 29 | br i1 %or.cond, label %c, label %a |
| 30 | |
| 31 | a: |
| 32 | ; CHECK: br |
| 33 | %shr.i4.i = lshr i64 %i0, 48 |
| 34 | %and.i5.i = and i64 %shr.i4.i, 32767 |
| 35 | %shr.i.i = lshr i64 %i1, 48 |
| 36 | %and.i2.i = and i64 %shr.i.i, 32767 |
| 37 | %cmp9.i = icmp ult i64 %and.i5.i, %and.i2.i |
| 38 | br i1 %cmp9.i, label %c, label %b |
| 39 | |
| 40 | b: |
| 41 | ; CHECK-NOT: br |
| 42 | %shr.i13.i9 = lshr i64 %i1, 48 |
| 43 | %and.i14.i10 = and i64 %shr.i13.i9, 32767 |
| 44 | %shr.i.i11 = lshr i64 %i0, 48 |
| 45 | %and.i11.i12 = and i64 %shr.i.i11, 32767 |
| 46 | %phitmp = icmp uge i64 %and.i14.i10, %and.i11.i12 |
| 47 | br label %c |
| 48 | |
| 49 | c: |
| 50 | %o2 = phi i1 [ false, %a ], [ %phitmp, %b ], [ false, %entry ] |
| 51 | ret i1 %o2 |
| 52 | } |
Nick Lewycky | 0a045bb | 2012-06-24 10:15:42 +0000 | [diff] [blame] | 53 | |
| 54 | ; PR13180 |
| 55 | define void @pr13180(i8 %p) { |
| 56 | entry: |
| 57 | %tobool = icmp eq i8 %p, 0 |
| 58 | br i1 %tobool, label %cond.false, label %cond.true |
| 59 | |
| 60 | cond.true: ; preds = %entry |
| 61 | br label %cond.end |
| 62 | |
| 63 | cond.false: ; preds = %entry |
| 64 | %phitmp = icmp eq i8 %p, 0 |
| 65 | br label %cond.end |
| 66 | |
| 67 | cond.end: ; preds = %cond.false, %cond.true |
| 68 | %cond = phi i1 [ undef, %cond.true ], [ %phitmp, %cond.false ] |
| 69 | unreachable |
| 70 | } |