| Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -simplifycfg -S | FileCheck %s |
| 2 | |
| 3 | define i32 @foo(i32 %x) optforfuzzing { |
| 4 | entry: |
| 5 | %x.addr = alloca i32, align 4 |
| 6 | store i32 %x, i32* %x.addr, align 4 |
| 7 | %0 = load i32, i32* %x.addr, align 4 |
| 8 | %cmp = icmp sgt i32 %0, 16 |
| 9 | br i1 %cmp, label %land.rhs, label %land.end |
| 10 | |
| 11 | land.rhs: |
| 12 | %1 = load i32, i32* %x.addr, align 4 |
| 13 | %cmp1 = icmp slt i32 %1, 32 |
| 14 | br label %land.end |
| 15 | |
| 16 | land.end: |
| 17 | %2 = phi i1 [ false, %entry ], [ %cmp1, %land.rhs ] |
| 18 | %conv = zext i1 %2 to i32 |
| 19 | ret i32 %conv |
| 20 | |
| 21 | ; CHECK-LABEL: define i32 @foo(i32 %x) |
| 22 | ; CHECK: br i1 %cmp, label %land.rhs, label %land.end |
| 23 | ; CHECK-LABEL: land.rhs: |
| 24 | ; CHECK: br label %land.end |
| 25 | ; CHECK-LABEL: land.end: |
| 26 | ; CHECK: phi {{.*}} %entry {{.*}} %land.rhs |
| 27 | } |
| 28 | |
| 29 | define i32 @bar(i32 %x) { |
| 30 | entry: |
| 31 | %x.addr = alloca i32, align 4 |
| 32 | store i32 %x, i32* %x.addr, align 4 |
| 33 | %0 = load i32, i32* %x.addr, align 4 |
| 34 | %cmp = icmp sgt i32 %0, 16 |
| 35 | br i1 %cmp, label %land.rhs, label %land.end |
| 36 | |
| 37 | land.rhs: |
| 38 | %1 = load i32, i32* %x.addr, align 4 |
| 39 | %cmp1 = icmp slt i32 %1, 32 |
| 40 | br label %land.end |
| 41 | |
| 42 | land.end: |
| 43 | %2 = phi i1 [ false, %entry ], [ %cmp1, %land.rhs ] |
| 44 | %conv = zext i1 %2 to i32 |
| 45 | ret i32 %conv |
| 46 | |
| 47 | ; CHECK-LABEL: define i32 @bar(i32 %x) |
| 48 | ; CHECK-NOT: br |
| 49 | } |