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