1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
5 define void @sdiv1_cmp_constants(i32 %x) {
6 ; CHECK-LABEL: @sdiv1_cmp_constants(
7 ; CHECK-NEXT: [[D:%.*]] = sdiv i32 1, [[X:%.*]]
8 ; CHECK-NEXT: [[C_0:%.*]] = icmp slt i32 0, [[D]]
9 ; CHECK-NEXT: call void @use(i1 [[C_0]])
10 ; CHECK-NEXT: call void @use(i1 false)
11 ; CHECK-NEXT: call void @use(i1 false)
12 ; CHECK-NEXT: [[C_3:%.*]] = icmp eq i32 1, [[D]]
13 ; CHECK-NEXT: call void @use(i1 [[C_3]])
14 ; CHECK-NEXT: [[C_4:%.*]] = icmp eq i32 0, [[D]]
15 ; CHECK-NEXT: call void @use(i1 [[C_4]])
16 ; CHECK-NEXT: call void @use(i1 false)
17 ; CHECK-NEXT: ret void
20 %c.0 = icmp slt i32 0, %d
21 call void @use(i1 %c.0)
22 %c.1 = icmp slt i32 1, %d
23 call void @use(i1 %c.1)
24 %c.2 = icmp slt i32 2, %d
25 call void @use(i1 %c.2)
27 %c.3 = icmp eq i32 1, %d
28 call void @use(i1 %c.3)
29 %c.4 = icmp eq i32 0, %d
30 call void @use(i1 %c.4)
31 %c.5 = icmp eq i32 2, %d
32 call void @use(i1 %c.5)
37 define void @sdiv1_cmp_range_1(i32 %x, i1 %c) {
38 ; CHECK-LABEL: @sdiv1_cmp_range_1(
39 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
41 ; CHECK-NEXT: br label [[BB3:%.*]]
43 ; CHECK-NEXT: br label [[BB3]]
45 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 1, [[BB1]] ], [ 2, [[BB2]] ]
46 ; CHECK-NEXT: [[D:%.*]] = sdiv i32 1, [[X:%.*]]
47 ; CHECK-NEXT: call void @use(i1 false)
48 ; CHECK-NEXT: [[C_1:%.*]] = icmp eq i32 [[P]], [[D]]
49 ; CHECK-NEXT: call void @use(i1 [[C_1]])
50 ; CHECK-NEXT: ret void
52 br i1 %c, label %bb1, label %bb2
59 %p = phi i32 [1, %bb1], [2, %bb2]
61 %c.0 = icmp slt i32 %p, %d
62 call void @use(i1 %c.0)
63 %c.1 = icmp eq i32 %p, %d
64 call void @use(i1 %c.1)
69 define void @sdiv1_cmp_range_2(i32 %x, i1 %c) {
70 ; CHECK-LABEL: @sdiv1_cmp_range_2(
71 ; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
73 ; CHECK-NEXT: br label [[BB3:%.*]]
75 ; CHECK-NEXT: br label [[BB3]]
77 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 3, [[BB1]] ], [ 2, [[BB2]] ]
78 ; CHECK-NEXT: [[D:%.*]] = sdiv i32 1, [[X:%.*]]
79 ; CHECK-NEXT: call void @use(i1 false)
80 ; CHECK-NEXT: call void @use(i1 false)
81 ; CHECK-NEXT: ret void
83 br i1 %c, label %bb1, label %bb2
90 %p = phi i32 [3, %bb1], [2, %bb2]
92 %c.0 = icmp slt i32 %p, %d
93 call void @use(i1 %c.0)
94 %c.1 = icmp eq i32 %p, %d
95 call void @use(i1 %c.1)
99 define void @urem_cmp_constants() {
100 ; CHECK-LABEL: @urem_cmp_constants(
101 ; CHECK-NEXT: call void @use(i1 true)
102 ; CHECK-NEXT: call void @use(i1 false)
103 ; CHECK-NEXT: call void @use(i1 true)
104 ; CHECK-NEXT: call void @use(i1 false)
105 ; CHECK-NEXT: [[UREM_3:%.*]] = urem i16 12704, 0
106 ; CHECK-NEXT: [[C_5:%.*]] = icmp eq i16 [[UREM_3]], 1
107 ; CHECK-NEXT: call void @use(i1 [[C_5]])
108 ; CHECK-NEXT: ret void
110 %sel = select i1 false, i16 0, i16 12704
111 %urem.1 = urem i16 %sel, 12704
112 %c.1 = icmp eq i16 %urem.1, 0
113 call void @use(i1 %c.1)
114 %c.2 = icmp eq i16 %urem.1, 1
115 call void @use(i1 %c.2)
116 %urem.2 = urem i16 %sel, 3
117 %c.3 = icmp eq i16 %urem.2, 2
118 call void @use(i1 %c.3)
119 %c.4 = icmp eq i16 %urem.2, 1
120 call void @use(i1 %c.4)
121 %urem.3 = urem i16 %sel, 0
122 %c.5 = icmp eq i16 %urem.3, 1
123 call void @use(i1 %c.5)
127 define void @srem_cmp_constants() {
128 ; CHECK-LABEL: @srem_cmp_constants(
129 ; CHECK-NEXT: call void @use(i1 true)
130 ; CHECK-NEXT: call void @use(i1 false)
131 ; CHECK-NEXT: call void @use(i1 true)
132 ; CHECK-NEXT: call void @use(i1 false)
133 ; CHECK-NEXT: [[SREM_3:%.*]] = urem i16 12704, 0
134 ; CHECK-NEXT: [[C_5:%.*]] = icmp eq i16 [[SREM_3]], 1
135 ; CHECK-NEXT: call void @use(i1 [[C_5]])
136 ; CHECK-NEXT: ret void
138 %sel = select i1 false, i16 0, i16 12704
139 %srem.1 = srem i16 %sel, 12704
140 %c.1 = icmp eq i16 %srem.1, 0
141 call void @use(i1 %c.1)
142 %c.2 = icmp eq i16 %srem.1, 1
143 call void @use(i1 %c.2)
144 %srem.2 = srem i16 %sel, 3
145 %c.3 = icmp eq i16 %srem.2, 2
146 call void @use(i1 %c.3)
147 %c.4 = icmp eq i16 %srem.2, 1
148 call void @use(i1 %c.4)
149 %srem.3 = srem i16 %sel, 0
150 %c.5 = icmp eq i16 %srem.3, 1
151 call void @use(i1 %c.5)