blob: a035f53d1aa21e4ee956254f1e53b3baa975790b [file] [log] [blame]
Matthias Braunc31032d2016-03-09 18:47:11 +00001; RUN: opt -S -instcombine -expensive-combines < %s | FileCheck %s
Hal Finkelf2199b22015-10-23 20:37:08 +00002target datalayout = "E-m:e-i64:64-n32:64"
3target 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
10define signext i32 @main() #1 {
11entry:
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
43attributes #0 = { nounwind readnone }
44attributes #1 = { nounwind }
45