llvm.org GIT mirror llvm / 7d56a78
[InstSimplify] fix some test names; NFC Too much division...the quotient is the answer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312943 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 2 years ago
3 changed file(s) with 56 addition(s) and 56 deletion(s). Raw diff Collapse all Expand all
5353 ret <2 x i1> %div
5454 }
5555
56 define i32 @udiv_quotient_known_smaller_than_constant_denom(i32 %x) {
57 ; CHECK-LABEL: @udiv_quotient_known_smaller_than_constant_denom(
56 define i32 @udiv_dividend_known_smaller_than_constant_divisor(i32 %x) {
57 ; CHECK-LABEL: @udiv_dividend_known_smaller_than_constant_divisor(
5858 ; CHECK-NEXT: ret i32 0
5959 ;
6060 %and = and i32 %x, 250
6262 ret i32 %div
6363 }
6464
65 define i32 @not_udiv_quotient_known_smaller_than_constant_denom(i32 %x) {
66 ; CHECK-LABEL: @not_udiv_quotient_known_smaller_than_constant_denom(
65 define i32 @not_udiv_dividend_known_smaller_than_constant_divisor(i32 %x) {
66 ; CHECK-LABEL: @not_udiv_dividend_known_smaller_than_constant_divisor(
6767 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 251
6868 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[AND]], 251
6969 ; CHECK-NEXT: ret i32 [[DIV]]
7373 ret i32 %div
7474 }
7575
76 define i32 @udiv_constant_quotient_known_smaller_than_denom(i32 %x) {
77 ; CHECK-LABEL: @udiv_constant_quotient_known_smaller_than_denom(
76 define i32 @udiv_constant_dividend_known_smaller_than_divisor(i32 %x) {
77 ; CHECK-LABEL: @udiv_constant_dividend_known_smaller_than_divisor(
7878 ; CHECK-NEXT: ret i32 0
7979 ;
8080 %or = or i32 %x, 251
8282 ret i32 %div
8383 }
8484
85 define i32 @not_udiv_constant_quotient_known_smaller_than_denom(i32 %x) {
86 ; CHECK-LABEL: @not_udiv_constant_quotient_known_smaller_than_denom(
85 define i32 @not_udiv_constant_dividend_known_smaller_than_divisor(i32 %x) {
86 ; CHECK-LABEL: @not_udiv_constant_dividend_known_smaller_than_divisor(
8787 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, 251
8888 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 251, [[OR]]
8989 ; CHECK-NEXT: ret i32 [[DIV]]
9595
9696 ; This would require computing known bits on both x and y. Is it worth doing?
9797
98 define i32 @udiv_quotient_known_smaller_than_denom(i32 %x, i32 %y) {
99 ; CHECK-LABEL: @udiv_quotient_known_smaller_than_denom(
98 define i32 @udiv_dividend_known_smaller_than_divisor(i32 %x, i32 %y) {
99 ; CHECK-LABEL: @udiv_dividend_known_smaller_than_divisor(
100100 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 250
101101 ; CHECK-NEXT: [[OR:%.*]] = or i32 %y, 251
102102 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[AND]], [[OR]]
108108 ret i32 %div
109109 }
110110
111 define i32 @not_udiv_quotient_known_smaller_than_denom(i32 %x, i32 %y) {
112 ; CHECK-LABEL: @not_udiv_quotient_known_smaller_than_denom(
111 define i32 @not_udiv_dividend_known_smaller_than_divisor(i32 %x, i32 %y) {
112 ; CHECK-LABEL: @not_udiv_dividend_known_smaller_than_divisor(
113113 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 251
114114 ; CHECK-NEXT: [[OR:%.*]] = or i32 %y, 251
115115 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[AND]], [[OR]]
103103 ret i32 %mod1
104104 }
105105
106 define i32 @urem_quotient_known_smaller_than_constant_denom(i32 %x) {
107 ; CHECK-LABEL: @urem_quotient_known_smaller_than_constant_denom(
106 define i32 @urem_dividend_known_smaller_than_constant_divisor(i32 %x) {
107 ; CHECK-LABEL: @urem_dividend_known_smaller_than_constant_divisor(
108108 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 250
109109 ; CHECK-NEXT: ret i32 [[AND]]
110110 ;
113113 ret i32 %r
114114 }
115115
116 define i32 @not_urem_quotient_known_smaller_than_constant_denom(i32 %x) {
117 ; CHECK-LABEL: @not_urem_quotient_known_smaller_than_constant_denom(
116 define i32 @not_urem_dividend_known_smaller_than_constant_divisor(i32 %x) {
117 ; CHECK-LABEL: @not_urem_dividend_known_smaller_than_constant_divisor(
118118 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 251
119119 ; CHECK-NEXT: [[R:%.*]] = urem i32 [[AND]], 251
120120 ; CHECK-NEXT: ret i32 [[R]]
124124 ret i32 %r
125125 }
126126
127 define i32 @urem_constant_quotient_known_smaller_than_denom(i32 %x) {
128 ; CHECK-LABEL: @urem_constant_quotient_known_smaller_than_denom(
127 define i32 @urem_constant_dividend_known_smaller_than_divisor(i32 %x) {
128 ; CHECK-LABEL: @urem_constant_dividend_known_smaller_than_divisor(
129129 ; CHECK-NEXT: ret i32 250
130130 ;
131131 %or = or i32 %x, 251
133133 ret i32 %r
134134 }
135135
136 define i32 @not_urem_constant_quotient_known_smaller_than_denom(i32 %x) {
137 ; CHECK-LABEL: @not_urem_constant_quotient_known_smaller_than_denom(
136 define i32 @not_urem_constant_dividend_known_smaller_than_divisor(i32 %x) {
137 ; CHECK-LABEL: @not_urem_constant_dividend_known_smaller_than_divisor(
138138 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, 251
139139 ; CHECK-NEXT: [[R:%.*]] = urem i32 251, [[OR]]
140140 ; CHECK-NEXT: ret i32 [[R]]
146146
147147 ; This would require computing known bits on both x and y. Is it worth doing?
148148
149 define i32 @urem_quotient_known_smaller_than_denom(i32 %x, i32 %y) {
150 ; CHECK-LABEL: @urem_quotient_known_smaller_than_denom(
149 define i32 @urem_dividend_known_smaller_than_divisor(i32 %x, i32 %y) {
150 ; CHECK-LABEL: @urem_dividend_known_smaller_than_divisor(
151151 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 250
152152 ; CHECK-NEXT: [[OR:%.*]] = or i32 %y, 251
153153 ; CHECK-NEXT: [[R:%.*]] = urem i32 [[AND]], [[OR]]
159159 ret i32 %r
160160 }
161161
162 define i32 @not_urem_quotient_known_smaller_than_denom(i32 %x, i32 %y) {
163 ; CHECK-LABEL: @not_urem_quotient_known_smaller_than_denom(
162 define i32 @not_urem_dividend_known_smaller_than_divisor(i32 %x, i32 %y) {
163 ; CHECK-LABEL: @not_urem_dividend_known_smaller_than_divisor(
164164 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 251
165165 ; CHECK-NEXT: [[OR:%.*]] = or i32 %y, 251
166166 ; CHECK-NEXT: [[R:%.*]] = urem i32 [[AND]], [[OR]]
8787 ret i32 %div
8888 }
8989
90 define i32 @sdiv_quotient_known_smaller_than_pos_divisor_clear_bits(i32 %x) {
91 ; CHECK-LABEL: @sdiv_quotient_known_smaller_than_pos_divisor_clear_bits(
90 define i32 @sdiv_dividend_known_smaller_than_pos_divisor_clear_bits(i32 %x) {
91 ; CHECK-LABEL: @sdiv_dividend_known_smaller_than_pos_divisor_clear_bits(
9292 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 253
9393 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[AND]], 254
9494 ; CHECK-NEXT: ret i32 [[DIV]]
9898 ret i32 %div
9999 }
100100
101 define i32 @not_sdiv_quotient_known_smaller_than_pos_divisor_clear_bits(i32 %x) {
102 ; CHECK-LABEL: @not_sdiv_quotient_known_smaller_than_pos_divisor_clear_bits(
101 define i32 @not_sdiv_dividend_known_smaller_than_pos_divisor_clear_bits(i32 %x) {
102 ; CHECK-LABEL: @not_sdiv_dividend_known_smaller_than_pos_divisor_clear_bits(
103103 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 253
104104 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[AND]], 253
105105 ; CHECK-NEXT: ret i32 [[DIV]]
109109 ret i32 %div
110110 }
111111
112 define i32 @sdiv_quotient_known_smaller_than_neg_divisor_clear_bits(i32 %x) {
113 ; CHECK-LABEL: @sdiv_quotient_known_smaller_than_neg_divisor_clear_bits(
112 define i32 @sdiv_dividend_known_smaller_than_neg_divisor_clear_bits(i32 %x) {
113 ; CHECK-LABEL: @sdiv_dividend_known_smaller_than_neg_divisor_clear_bits(
114114 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 253
115115 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[AND]], -254
116116 ; CHECK-NEXT: ret i32 [[DIV]]
120120 ret i32 %div
121121 }
122122
123 define i32 @not_sdiv_quotient_known_smaller_than_neg_divisor_clear_bits(i32 %x) {
124 ; CHECK-LABEL: @not_sdiv_quotient_known_smaller_than_neg_divisor_clear_bits(
123 define i32 @not_sdiv_dividend_known_smaller_than_neg_divisor_clear_bits(i32 %x) {
124 ; CHECK-LABEL: @not_sdiv_dividend_known_smaller_than_neg_divisor_clear_bits(
125125 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 253
126126 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[AND]], -253
127127 ; CHECK-NEXT: ret i32 [[DIV]]
131131 ret i32 %div
132132 }
133133
134 define i32 @sdiv_quotient_known_smaller_than_pos_divisor_set_bits(i32 %x) {
135 ; CHECK-LABEL: @sdiv_quotient_known_smaller_than_pos_divisor_set_bits(
134 define i32 @sdiv_dividend_known_smaller_than_pos_divisor_set_bits(i32 %x) {
135 ; CHECK-LABEL: @sdiv_dividend_known_smaller_than_pos_divisor_set_bits(
136136 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, -253
137137 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[OR]], 254
138138 ; CHECK-NEXT: ret i32 [[DIV]]
142142 ret i32 %div
143143 }
144144
145 define i32 @not_sdiv_quotient_known_smaller_than_pos_divisor_set_bits(i32 %x) {
146 ; CHECK-LABEL: @not_sdiv_quotient_known_smaller_than_pos_divisor_set_bits(
145 define i32 @not_sdiv_dividend_known_smaller_than_pos_divisor_set_bits(i32 %x) {
146 ; CHECK-LABEL: @not_sdiv_dividend_known_smaller_than_pos_divisor_set_bits(
147147 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, -253
148148 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[OR]], 253
149149 ; CHECK-NEXT: ret i32 [[DIV]]
153153 ret i32 %div
154154 }
155155
156 define i32 @sdiv_quotient_known_smaller_than_neg_divisor_set_bits(i32 %x) {
157 ; CHECK-LABEL: @sdiv_quotient_known_smaller_than_neg_divisor_set_bits(
156 define i32 @sdiv_dividend_known_smaller_than_neg_divisor_set_bits(i32 %x) {
157 ; CHECK-LABEL: @sdiv_dividend_known_smaller_than_neg_divisor_set_bits(
158158 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, -253
159159 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[OR]], -254
160160 ; CHECK-NEXT: ret i32 [[DIV]]
164164 ret i32 %div
165165 }
166166
167 define i32 @not_sdiv_quotient_known_smaller_than_neg_divisor_set_bits(i32 %x) {
168 ; CHECK-LABEL: @not_sdiv_quotient_known_smaller_than_neg_divisor_set_bits(
167 define i32 @not_sdiv_dividend_known_smaller_than_neg_divisor_set_bits(i32 %x) {
168 ; CHECK-LABEL: @not_sdiv_dividend_known_smaller_than_neg_divisor_set_bits(
169169 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, -253
170170 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[OR]], -253
171171 ; CHECK-NEXT: ret i32 [[DIV]]
263263 ret i32 %rem
264264 }
265265
266 define i32 @srem_quotient_known_smaller_than_pos_divisor_clear_bits(i32 %x) {
267 ; CHECK-LABEL: @srem_quotient_known_smaller_than_pos_divisor_clear_bits(
266 define i32 @srem_dividend_known_smaller_than_pos_divisor_clear_bits(i32 %x) {
267 ; CHECK-LABEL: @srem_dividend_known_smaller_than_pos_divisor_clear_bits(
268268 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 253
269269 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[AND]], 254
270270 ; CHECK-NEXT: ret i32 [[REM]]
274274 ret i32 %rem
275275 }
276276
277 define i32 @not_srem_quotient_known_smaller_than_pos_divisor_clear_bits(i32 %x) {
278 ; CHECK-LABEL: @not_srem_quotient_known_smaller_than_pos_divisor_clear_bits(
277 define i32 @not_srem_dividend_known_smaller_than_pos_divisor_clear_bits(i32 %x) {
278 ; CHECK-LABEL: @not_srem_dividend_known_smaller_than_pos_divisor_clear_bits(
279279 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 253
280280 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[AND]], 253
281281 ; CHECK-NEXT: ret i32 [[REM]]
285285 ret i32 %rem
286286 }
287287
288 define i32 @srem_quotient_known_smaller_than_neg_divisor_clear_bits(i32 %x) {
289 ; CHECK-LABEL: @srem_quotient_known_smaller_than_neg_divisor_clear_bits(
288 define i32 @srem_dividend_known_smaller_than_neg_divisor_clear_bits(i32 %x) {
289 ; CHECK-LABEL: @srem_dividend_known_smaller_than_neg_divisor_clear_bits(
290290 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 253
291291 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[AND]], -254
292292 ; CHECK-NEXT: ret i32 [[REM]]
296296 ret i32 %rem
297297 }
298298
299 define i32 @not_srem_quotient_known_smaller_than_neg_divisor_clear_bits(i32 %x) {
300 ; CHECK-LABEL: @not_srem_quotient_known_smaller_than_neg_divisor_clear_bits(
299 define i32 @not_srem_dividend_known_smaller_than_neg_divisor_clear_bits(i32 %x) {
300 ; CHECK-LABEL: @not_srem_dividend_known_smaller_than_neg_divisor_clear_bits(
301301 ; CHECK-NEXT: [[AND:%.*]] = and i32 %x, 253
302302 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[AND]], -253
303303 ; CHECK-NEXT: ret i32 [[REM]]
307307 ret i32 %rem
308308 }
309309
310 define i32 @srem_quotient_known_smaller_than_pos_divisor_set_bits(i32 %x) {
311 ; CHECK-LABEL: @srem_quotient_known_smaller_than_pos_divisor_set_bits(
310 define i32 @srem_dividend_known_smaller_than_pos_divisor_set_bits(i32 %x) {
311 ; CHECK-LABEL: @srem_dividend_known_smaller_than_pos_divisor_set_bits(
312312 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, -253
313313 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[OR]], 254
314314 ; CHECK-NEXT: ret i32 [[REM]]
318318 ret i32 %rem
319319 }
320320
321 define i32 @not_srem_quotient_known_smaller_than_pos_divisor_set_bits(i32 %x) {
322 ; CHECK-LABEL: @not_srem_quotient_known_smaller_than_pos_divisor_set_bits(
321 define i32 @not_srem_dividend_known_smaller_than_pos_divisor_set_bits(i32 %x) {
322 ; CHECK-LABEL: @not_srem_dividend_known_smaller_than_pos_divisor_set_bits(
323323 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, -253
324324 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[OR]], 253
325325 ; CHECK-NEXT: ret i32 [[REM]]
329329 ret i32 %rem
330330 }
331331
332 define i32 @srem_quotient_known_smaller_than_neg_divisor_set_bits(i32 %x) {
333 ; CHECK-LABEL: @srem_quotient_known_smaller_than_neg_divisor_set_bits(
332 define i32 @srem_dividend_known_smaller_than_neg_divisor_set_bits(i32 %x) {
333 ; CHECK-LABEL: @srem_dividend_known_smaller_than_neg_divisor_set_bits(
334334 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, -253
335335 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[OR]], -254
336336 ; CHECK-NEXT: ret i32 [[REM]]
340340 ret i32 %rem
341341 }
342342
343 define i32 @not_srem_quotient_known_smaller_than_neg_divisor_set_bits(i32 %x) {
344 ; CHECK-LABEL: @not_srem_quotient_known_smaller_than_neg_divisor_set_bits(
343 define i32 @not_srem_dividend_known_smaller_than_neg_divisor_set_bits(i32 %x) {
344 ; CHECK-LABEL: @not_srem_dividend_known_smaller_than_neg_divisor_set_bits(
345345 ; CHECK-NEXT: [[OR:%.*]] = or i32 %x, -253
346346 ; CHECK-NEXT: [[REM:%.*]] = srem i32 [[OR]], -253
347347 ; CHECK-NEXT: ret i32 [[REM]]