Matthias Braun | c31032d | 2016-03-09 18:47:11 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -instcombine -expensive-combines < %s | FileCheck %s |
Hal Finkel | f2199b2 | 2015-10-23 20:37:08 +0000 | [diff] [blame] | 2 | target datalayout = "E-m:e-i64:64-n32:64" |
| 3 | target triple = "powerpc64-unknown-linux-gnu" |
| 4 | |
| 5 | @d = global i32 15, align 4 |
| 6 | @b = global i32* @d, align 8 |
| 7 | @a = common global i32 0, align 4 |
| 8 | |
| 9 | ; Function Attrs: nounwind |
| 10 | define signext i32 @main() #1 { |
| 11 | entry: |
| 12 | %0 = load i32*, i32** @b, align 8 |
| 13 | %1 = load i32, i32* @a, align 4 |
| 14 | %lnot = icmp eq i32 %1, 0 |
| 15 | %lnot.ext = zext i1 %lnot to i32 |
| 16 | %shr.i = lshr i32 2072, %lnot.ext |
| 17 | %call.lobit = lshr i32 %shr.i, 7 |
| 18 | %2 = and i32 %call.lobit, 1 |
| 19 | %3 = load i32, i32* %0, align 4 |
| 20 | %or = or i32 %2, %3 |
| 21 | store i32 %or, i32* %0, align 4 |
| 22 | %4 = load i32, i32* @a, align 4 |
| 23 | %lnot.1 = icmp eq i32 %4, 0 |
| 24 | %lnot.ext.1 = zext i1 %lnot.1 to i32 |
| 25 | %shr.i.1 = lshr i32 2072, %lnot.ext.1 |
| 26 | %call.lobit.1 = lshr i32 %shr.i.1, 7 |
| 27 | %5 = and i32 %call.lobit.1, 1 |
| 28 | %or.1 = or i32 %5, %or |
| 29 | store i32 %or.1, i32* %0, align 4 |
| 30 | ret i32 %or.1 |
| 31 | |
| 32 | ; Check that both InstCombine and InstSimplify can use computeKnownBits to |
| 33 | ; realize that: |
| 34 | ; ((2072 >> (L == 0)) >> 7) & 1 |
| 35 | ; is always zero. |
| 36 | |
| 37 | ; CHECK-LABEL: @main |
| 38 | ; CHECK: %[[V1:[0-9]+]] = load i32*, i32** @b, align 8 |
| 39 | ; CHECK: %[[V2:[0-9]+]] = load i32, i32* %[[V1]], align 4 |
| 40 | ; CHECK: ret i32 %[[V2]] |
| 41 | } |
| 42 | |
| 43 | attributes #0 = { nounwind readnone } |
| 44 | attributes #1 = { nounwind } |
| 45 | |