xref: /llvm-project/llvm/test/Transforms/InstCombine/all-bits-shift.ll (revision 4ab40eca080965c65802710e39adbb78c4ce7bde)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -passes=instcombine < %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 ptr @d, align 8
8@a = common global i32 0, align 4
9
10; Check that both InstCombine and InstSimplify can use computeKnownBits to
11; realize that:
12;   ((2072 >> (L == 0)) >> 7) & 1
13; is always zero.
14define signext i32 @main() #1 {
15; CHECK-LABEL: @main(
16; CHECK-NEXT:  entry:
17; CHECK-NEXT:    [[TMP0:%.*]] = load ptr, ptr @b, align 8
18; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[TMP0]], align 4
19; CHECK-NEXT:    ret i32 [[TMP1]]
20;
21entry:
22  %0 = load ptr, ptr @b, align 8
23  %1 = load i32, ptr @a, align 4
24  %lnot = icmp eq i32 %1, 0
25  %lnot.ext = zext i1 %lnot to i32
26  %shr.i = lshr i32 2072, %lnot.ext
27  %call.lobit = lshr i32 %shr.i, 7
28  %2 = and i32 %call.lobit, 1
29  %3 = load i32, ptr %0, align 4
30  %or = or i32 %2, %3
31  store i32 %or, ptr %0, align 4
32  %4 = load i32, ptr @a, align 4
33  %lnot.1 = icmp eq i32 %4, 0
34  %lnot.ext.1 = zext i1 %lnot.1 to i32
35  %shr.i.1 = lshr i32 2072, %lnot.ext.1
36  %call.lobit.1 = lshr i32 %shr.i.1, 7
37  %5 = and i32 %call.lobit.1, 1
38  %or.1 = or i32 %5, %or
39  store i32 %or.1, ptr %0, align 4
40  ret i32 %or.1
41
42}
43
44attributes #0 = { nounwind readnone }
45attributes #1 = { nounwind }
46
47