Guozhi Wei | ae541f6 | 2016-10-25 20:43:42 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -instcombine -S | FileCheck %s |
| 2 | |
| 3 | |
| 4 | @i = constant i32 1, align 4 |
| 5 | @f = constant float 0x3FF19999A0000000, align 4 |
| 6 | @cmp = common global i32 0, align 4 |
| 7 | @resf = common global float* null, align 8 |
| 8 | @resi = common global i32* null, align 8 |
| 9 | |
| 10 | define i32 @foo() { |
| 11 | entry: |
| 12 | br label %while.cond |
| 13 | |
| 14 | while.cond: |
| 15 | %res.0 = phi i32* [ null, %entry ], [ @i, %if.then ], [ bitcast (float* @f to i32*), %if.else ] |
| 16 | %0 = load i32, i32* @cmp, align 4 |
| 17 | %shr = ashr i32 %0, 1 |
| 18 | store i32 %shr, i32* @cmp, align 4 |
| 19 | %tobool = icmp ne i32 %shr, 0 |
| 20 | br i1 %tobool, label %while.body, label %while.end |
| 21 | |
| 22 | while.body: |
| 23 | %and = and i32 %shr, 1 |
| 24 | %tobool1 = icmp ne i32 %and, 0 |
| 25 | br i1 %tobool1, label %if.then, label %if.else |
| 26 | |
| 27 | if.then: |
| 28 | br label %while.cond |
| 29 | |
| 30 | if.else: |
| 31 | br label %while.cond |
| 32 | |
| 33 | while.end: |
| 34 | %1 = bitcast i32* %res.0 to float* |
| 35 | store float* %1, float** @resf, align 8 |
| 36 | store i32* %res.0, i32** @resi, align 8 |
| 37 | ret i32 0 |
| 38 | |
| 39 | ; CHECK-NOT: bitcast i32 |
| 40 | } |
| 41 | |