1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -constraint-elimination -S %s | FileCheck %s
6 define void @loop_pointer_iv(i8* %start, i8* %end, i8* %upper) {
7 ; CHECK-LABEL: @loop_pointer_iv(
9 ; CHECK-NEXT: [[END_LT_UPPER:%.*]] = icmp ult i8* [[END:%.*]], [[UPPER:%.*]]
10 ; CHECK-NEXT: br i1 [[END_LT_UPPER]], label [[LOOP_HEADER:%.*]], label [[EXIT:%.*]]
12 ; CHECK-NEXT: [[IV:%.*]] = phi i8* [ [[START:%.*]], [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]
13 ; CHECK-NEXT: [[C_2:%.*]] = icmp ule i8* [[IV]], [[END]]
14 ; CHECK-NEXT: call void @use(i1 [[C_2]])
15 ; CHECK-NEXT: [[T_2:%.*]] = icmp uge i8* [[IV]], [[START]]
16 ; CHECK-NEXT: call void @use(i1 [[T_2]])
17 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8* [[IV]], [[END]]
18 ; CHECK-NEXT: br i1 [[C_1]], label [[LOOP_LATCH]], label [[EXIT]]
20 ; CHECK-NEXT: [[T_1:%.*]] = icmp ult i8* [[IV]], [[UPPER]]
21 ; CHECK-NEXT: call void @use(i1 true)
22 ; CHECK-NEXT: [[IV_NEXT]] = getelementptr inbounds i8, i8* [[IV]], i8 1
23 ; CHECK-NEXT: br label [[LOOP_HEADER]]
25 ; CHECK-NEXT: ret void
28 %end.lt.upper = icmp ult i8* %end, %upper
29 br i1 %end.lt.upper, label %loop.header, label %exit
32 %iv = phi i8* [ %start, %entry ], [ %iv.next, %loop.latch ]
33 %c.2 = icmp ule i8* %iv, %end
34 call void @use(i1 %c.2)
36 %t.2 = icmp uge i8* %iv, %start
37 call void @use(i1 %t.2)
39 %c.1 = icmp ule i8* %iv, %end
40 br i1 %c.1, label %loop.latch, label %exit
43 %t.1 = icmp ult i8* %iv, %upper
44 call void @use(i1 %t.1)
46 %iv.next = getelementptr inbounds i8, i8* %iv, i8 1
53 define void @loop_pointer_iv_null_start(i8* %end, i8* %upper) {
54 ; CHECK-LABEL: @loop_pointer_iv_null_start(
56 ; CHECK-NEXT: [[END_LT_UPPER:%.*]] = icmp ult i8* [[END:%.*]], [[UPPER:%.*]]
57 ; CHECK-NEXT: br i1 [[END_LT_UPPER]], label [[LOOP_HEADER:%.*]], label [[EXIT:%.*]]
59 ; CHECK-NEXT: [[IV:%.*]] = phi i8* [ null, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]
60 ; CHECK-NEXT: [[C_1:%.*]] = icmp ule i8* [[IV]], [[END]]
61 ; CHECK-NEXT: call void @use(i1 [[C_1]])
62 ; CHECK-NEXT: [[C_2:%.*]] = icmp uge i8* [[IV]], null
63 ; CHECK-NEXT: call void @use(i1 [[C_2]])
64 ; CHECK-NEXT: [[C_3:%.*]] = icmp ule i8* [[IV]], [[END]]
65 ; CHECK-NEXT: br i1 [[C_3]], label [[LOOP_LATCH]], label [[EXIT]]
67 ; CHECK-NEXT: [[C_4:%.*]] = icmp ult i8* [[IV]], [[UPPER]]
68 ; CHECK-NEXT: call void @use(i1 true)
69 ; CHECK-NEXT: [[IV_NEXT]] = getelementptr inbounds i8, i8* [[IV]], i8 1
70 ; CHECK-NEXT: br label [[LOOP_HEADER]]
72 ; CHECK-NEXT: ret void
75 %end.lt.upper = icmp ult i8* %end, %upper
76 br i1 %end.lt.upper, label %loop.header, label %exit
79 %iv = phi i8* [ null, %entry ], [ %iv.next, %loop.latch ]
80 %c.1 = icmp ule i8* %iv, %end
81 call void @use(i1 %c.1)
83 %c.2 = icmp uge i8* %iv, null
84 call void @use(i1 %c.2)
86 %c.3 = icmp ule i8* %iv, %end
87 br i1 %c.3, label %loop.latch, label %exit
90 %c.4 = icmp ult i8* %iv, %upper
91 call void @use(i1 %c.4)
93 %iv.next = getelementptr inbounds i8, i8* %iv, i8 1
100 define void @test_start_null_cmp_null(i8* %start) {
101 ; CHECK-LABEL: @test_start_null_cmp_null(
103 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
104 ; CHECK: loop.header:
105 ; CHECK-NEXT: [[IV:%.*]] = phi i8* [ null, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]
106 ; CHECK-NEXT: [[CMP_I_I122:%.*]] = icmp eq i8* [[IV]], null
107 ; CHECK-NEXT: br i1 [[CMP_I_I122]], label [[LOOP_LATCH]], label [[EXIT:%.*]]
109 ; CHECK-NEXT: [[IV_NEXT]] = getelementptr inbounds i8, i8* [[IV]], i64 1
110 ; CHECK-NEXT: br label [[LOOP_HEADER]]
112 ; CHECK-NEXT: ret void
115 br label %loop.header
118 %iv = phi i8* [ null, %entry ], [ %iv.next, %loop.latch ]
119 %cmp.i.i122 = icmp eq i8* %iv, null
120 br i1 %cmp.i.i122, label %loop.latch, label %exit
123 %iv.next = getelementptr inbounds i8, i8* %iv, i64 1
124 br label %loop.header