1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
5 declare void @llvm.assume(i1)
7 define void @basic(i32 %v) {
9 ; CHECK-NEXT: [[A1:%.*]] = icmp ult i32 [[V:%.*]], 10
10 ; CHECK-NEXT: call void @llvm.assume(i1 [[A1]])
11 ; CHECK-NEXT: [[A2:%.*]] = icmp ugt i32 [[V]], 5
12 ; CHECK-NEXT: call void @llvm.assume(i1 [[A2]])
13 ; CHECK-NEXT: call void @use(i1 true)
14 ; CHECK-NEXT: [[C2:%.*]] = icmp ult i32 [[V]], 9
15 ; CHECK-NEXT: call void @use(i1 [[C2]])
16 ; CHECK-NEXT: call void @use(i1 false)
17 ; CHECK-NEXT: [[C4:%.*]] = icmp ugt i32 [[V]], 8
18 ; CHECK-NEXT: call void @use(i1 [[C4]])
19 ; CHECK-NEXT: call void @use(i1 true)
20 ; CHECK-NEXT: [[C6:%.*]] = icmp ugt i32 [[V]], 6
21 ; CHECK-NEXT: call void @use(i1 [[C6]])
22 ; CHECK-NEXT: call void @use(i1 false)
23 ; CHECK-NEXT: [[C8:%.*]] = icmp ult i32 [[V]], 7
24 ; CHECK-NEXT: call void @use(i1 [[C8]])
25 ; CHECK-NEXT: ret void
27 %a1 = icmp ult i32 %v, 10
28 call void @llvm.assume(i1 %a1)
29 %a2 = icmp ugt i32 %v, 5
30 call void @llvm.assume(i1 %a2)
31 %c1 = icmp ult i32 %v, 10
32 call void @use(i1 %c1)
33 %c2 = icmp ult i32 %v, 9
34 call void @use(i1 %c2)
35 %c3 = icmp ugt i32 %v, 9
36 call void @use(i1 %c3)
37 %c4 = icmp ugt i32 %v, 8
38 call void @use(i1 %c4)
39 %c5 = icmp ugt i32 %v, 5
40 call void @use(i1 %c5)
41 %c6 = icmp ugt i32 %v, 6
42 call void @use(i1 %c6)
43 %c7 = icmp ult i32 %v, 6
44 call void @use(i1 %c7)
45 %c8 = icmp ult i32 %v, 7
46 call void @use(i1 %c8)
50 define void @nonnull(ptr %v) {
51 ; CHECK-LABEL: @nonnull(
52 ; CHECK-NEXT: [[A:%.*]] = icmp ne ptr [[V:%.*]], null
53 ; CHECK-NEXT: call void @llvm.assume(i1 [[A]])
54 ; CHECK-NEXT: call void @use(i1 false)
55 ; CHECK-NEXT: call void @use(i1 true)
56 ; CHECK-NEXT: call void @use(i1 false)
57 ; CHECK-NEXT: call void @use(i1 true)
58 ; CHECK-NEXT: ret void
60 %a = icmp ne ptr %v, null
61 call void @llvm.assume(i1 %a)
62 %c1 = icmp eq ptr %v, null
63 call void @use(i1 %c1)
64 %c2 = icmp ne ptr %v, null
65 call void @use(i1 %c2)
66 %c3 = icmp eq ptr null, %v
67 call void @use(i1 %c3)
68 %c4 = icmp ne ptr null, %v
69 call void @use(i1 %c4)