1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=ipsccp %s | FileCheck %s
6 define i1 @test1(i64 %x) {
9 ; CHECK-NEXT: [[COND:%.*]] = icmp ugt i64 [[X:%.*]], 65535
10 ; CHECK-NEXT: call void @llvm.assume(i1 [[COND]])
11 ; CHECK-NEXT: [[MASK:%.*]] = and i64 [[X]], -65521
12 ; CHECK-NEXT: ret i1 false
15 %cond = icmp ugt i64 %x, 65535
16 call void @llvm.assume(i1 %cond)
17 %mask = and i64 %x, -65521
18 %cmp = icmp eq i64 %mask, 0
22 define void @test.and(i64 %x, i64 %y) {
23 ; CHECK-LABEL: @test.and(
25 ; CHECK-NEXT: [[C0:%.*]] = icmp uge i64 [[X:%.*]], 138
26 ; CHECK-NEXT: [[C1:%.*]] = icmp ule i64 [[X]], 161
27 ; CHECK-NEXT: call void @llvm.assume(i1 [[C0]])
28 ; CHECK-NEXT: call void @llvm.assume(i1 [[C1]])
29 ; CHECK-NEXT: [[C2:%.*]] = icmp uge i64 [[Y:%.*]], 186
30 ; CHECK-NEXT: [[C3:%.*]] = icmp ule i64 [[Y]], 188
31 ; CHECK-NEXT: call void @llvm.assume(i1 [[C2]])
32 ; CHECK-NEXT: call void @llvm.assume(i1 [[C3]])
33 ; CHECK-NEXT: [[AND:%.*]] = and i64 [[X]], [[Y]]
34 ; CHECK-NEXT: call void @use(i1 false)
35 ; CHECK-NEXT: [[R1:%.*]] = icmp ult i64 [[AND]], 137
36 ; CHECK-NEXT: call void @use(i1 [[R1]])
37 ; CHECK-NEXT: ret void
40 %c0 = icmp uge i64 %x, 138 ; 0b10001010
41 %c1 = icmp ule i64 %x, 161 ; 0b10100000
42 call void @llvm.assume(i1 %c0)
43 call void @llvm.assume(i1 %c1)
44 %c2 = icmp uge i64 %y, 186 ; 0b10111010
45 %c3 = icmp ule i64 %y, 188 ; 0b10111110
46 call void @llvm.assume(i1 %c2)
47 call void @llvm.assume(i1 %c3)
49 %r0 = icmp ult i64 %and, 136 ; 0b10001000
50 call void @use(i1 %r0) ; false
51 %r1 = icmp ult i64 %and, 137
52 call void @use(i1 %r1) ; unknown
56 define void @test.or(i64 %x, i64 %y) {
57 ; CHECK-LABEL: @test.or(
59 ; CHECK-NEXT: [[C0:%.*]] = icmp ule i64 [[X:%.*]], 117
60 ; CHECK-NEXT: [[C1:%.*]] = icmp uge i64 [[X]], 95
61 ; CHECK-NEXT: call void @llvm.assume(i1 [[C0]])
62 ; CHECK-NEXT: call void @llvm.assume(i1 [[C1]])
63 ; CHECK-NEXT: [[C2:%.*]] = icmp ule i64 [[Y:%.*]], 69
64 ; CHECK-NEXT: [[C3:%.*]] = icmp uge i64 [[Y]], 67
65 ; CHECK-NEXT: call void @llvm.assume(i1 [[C2]])
66 ; CHECK-NEXT: call void @llvm.assume(i1 [[C3]])
67 ; CHECK-NEXT: [[OR:%.*]] = or i64 [[X]], [[Y]]
68 ; CHECK-NEXT: call void @use(i1 false)
69 ; CHECK-NEXT: [[R1:%.*]] = icmp ugt i64 [[OR]], 118
70 ; CHECK-NEXT: call void @use(i1 [[R1]])
71 ; CHECK-NEXT: ret void
74 %c0 = icmp ule i64 %x, 117 ; 0b01110101
75 %c1 = icmp uge i64 %x, 95 ; 0b01011111
76 call void @llvm.assume(i1 %c0)
77 call void @llvm.assume(i1 %c1)
78 %c2 = icmp ule i64 %y, 69 ; 0b01000101
79 %c3 = icmp uge i64 %y, 67 ; 0b01000011
80 call void @llvm.assume(i1 %c2)
81 call void @llvm.assume(i1 %c3)
83 %r0 = icmp ugt i64 %or, 119 ; 0b01110111
84 call void @use(i1 %r0) ; false
85 %r1 = icmp ugt i64 %or, 118
86 call void @use(i1 %r1) ; unknown