@@ -211,6 +211,10 @@ define <3 x i32> @xor_constmask_vec_undef(<3 x i32> %x, <3 x i32> %y) {
211
211
; Commutativity.
212
212
; ============================================================================ ;
213
213
214
+ ; Used to make sure that the IR complexity sorting does not interfere.
215
+ declare i32 @gen32 ()
216
+
217
+
214
218
define i32 @or_commutative0 (i32 %x , i32 %y , i32 %m ) {
215
219
; CHECK-LABEL: @or_commutative0(
216
220
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
@@ -226,14 +230,16 @@ define i32 @or_commutative0(i32 %x, i32 %y, i32 %m) {
226
230
ret i32 %or
227
231
}
228
232
229
- define i32 @or_commutative1 (i32 %x , i32 %y , i32 % m ) {
233
+ define i32 @or_commutative1 (i32 %x , i32 %m ) {
230
234
; CHECK-LABEL: @or_commutative1(
235
+ ; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
231
236
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
232
237
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
233
- ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG ]], [[Y:%.* ]]
238
+ ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y ]], [[NEG ]]
234
239
; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[AND1]]
235
240
; CHECK-NEXT: ret i32 [[OR]]
236
241
;
242
+ %y = call i32 @gen32 ()
237
243
%and = and i32 %x , %m
238
244
%neg = xor i32 %m , -1
239
245
%and1 = and i32 %y , %neg ; swapped order
@@ -257,14 +263,16 @@ define i32 @or_commutative2(i32 %x, i32 %y, i32 %m) {
257
263
}
258
264
259
265
260
- define i32 @or_commutative3 (i32 %x , i32 %y , i32 % m ) {
266
+ define i32 @or_commutative3 (i32 %x , i32 %m ) {
261
267
; CHECK-LABEL: @or_commutative3(
268
+ ; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
262
269
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
263
270
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
264
- ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG ]], [[Y:%.* ]]
271
+ ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y ]], [[NEG ]]
265
272
; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND]], [[AND1]]
266
273
; CHECK-NEXT: ret i32 [[OR]]
267
274
;
275
+ %y = call i32 @gen32 ()
268
276
%and = and i32 %m , %x ; swapped order
269
277
%neg = xor i32 %m , -1
270
278
%and1 = and i32 %y , %neg ; swapped order
@@ -287,14 +295,16 @@ define i32 @or_commutative4(i32 %x, i32 %y, i32 %m) {
287
295
ret i32 %or
288
296
}
289
297
290
- define i32 @or_commutative5 (i32 %x , i32 %y , i32 % m ) {
298
+ define i32 @or_commutative5 (i32 %x , i32 %m ) {
291
299
; CHECK-LABEL: @or_commutative5(
300
+ ; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
292
301
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
293
302
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
294
- ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG ]], [[Y:%.* ]]
303
+ ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y ]], [[NEG ]]
295
304
; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND1]], [[AND]]
296
305
; CHECK-NEXT: ret i32 [[OR]]
297
306
;
307
+ %y = call i32 @gen32 ()
298
308
%and = and i32 %x , %m
299
309
%neg = xor i32 %m , -1
300
310
%and1 = and i32 %y , %neg ; swapped order
@@ -303,14 +313,16 @@ define i32 @or_commutative5(i32 %x, i32 %y, i32 %m) {
303
313
}
304
314
305
315
306
- define i32 @or_commutative6 (i32 %x , i32 %y , i32 % m ) {
316
+ define i32 @or_commutative6 (i32 %x , i32 %m ) {
307
317
; CHECK-LABEL: @or_commutative6(
318
+ ; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
308
319
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
309
320
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
310
- ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG ]], [[Y:%.* ]]
321
+ ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y ]], [[NEG ]]
311
322
; CHECK-NEXT: [[OR:%.*]] = or i32 [[AND1]], [[AND]]
312
323
; CHECK-NEXT: ret i32 [[OR]]
313
324
;
325
+ %y = call i32 @gen32 ()
314
326
%and = and i32 %m , %x ; swapped order
315
327
%neg = xor i32 %m , -1
316
328
%and1 = and i32 %y , %neg ; swapped order
@@ -335,14 +347,16 @@ define i32 @xor_commutative0(i32 %x, i32 %y, i32 %m) {
335
347
ret i32 %xor
336
348
}
337
349
338
- define i32 @xor_commutative1 (i32 %x , i32 %y , i32 % m ) {
350
+ define i32 @xor_commutative1 (i32 %x , i32 %m ) {
339
351
; CHECK-LABEL: @xor_commutative1(
352
+ ; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
340
353
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
341
354
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
342
- ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG ]], [[Y:%.* ]]
355
+ ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y ]], [[NEG ]]
343
356
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[AND]], [[AND1]]
344
357
; CHECK-NEXT: ret i32 [[XOR]]
345
358
;
359
+ %y = call i32 @gen32 ()
346
360
%and = and i32 %x , %m
347
361
%neg = xor i32 %m , -1
348
362
%and1 = and i32 %y , %neg ; swapped order
@@ -366,14 +380,16 @@ define i32 @xor_commutative2(i32 %x, i32 %y, i32 %m) {
366
380
}
367
381
368
382
369
- define i32 @xor_commutative3 (i32 %x , i32 %y , i32 % m ) {
383
+ define i32 @xor_commutative3 (i32 %x , i32 %m ) {
370
384
; CHECK-LABEL: @xor_commutative3(
385
+ ; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
371
386
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
372
387
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
373
- ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG ]], [[Y:%.* ]]
388
+ ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y ]], [[NEG ]]
374
389
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[AND]], [[AND1]]
375
390
; CHECK-NEXT: ret i32 [[XOR]]
376
391
;
392
+ %y = call i32 @gen32 ()
377
393
%and = and i32 %m , %x ; swapped order
378
394
%neg = xor i32 %m , -1
379
395
%and1 = and i32 %y , %neg ; swapped order
@@ -396,14 +412,16 @@ define i32 @xor_commutative4(i32 %x, i32 %y, i32 %m) {
396
412
ret i32 %xor
397
413
}
398
414
399
- define i32 @xor_commutative5 (i32 %x , i32 %y , i32 % m ) {
415
+ define i32 @xor_commutative5 (i32 %x , i32 %m ) {
400
416
; CHECK-LABEL: @xor_commutative5(
417
+ ; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
401
418
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], [[M:%.*]]
402
419
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
403
- ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG ]], [[Y:%.* ]]
420
+ ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y ]], [[NEG ]]
404
421
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[AND1]], [[AND]]
405
422
; CHECK-NEXT: ret i32 [[XOR]]
406
423
;
424
+ %y = call i32 @gen32 ()
407
425
%and = and i32 %x , %m
408
426
%neg = xor i32 %m , -1
409
427
%and1 = and i32 %y , %neg ; swapped order
@@ -412,14 +430,16 @@ define i32 @xor_commutative5(i32 %x, i32 %y, i32 %m) {
412
430
}
413
431
414
432
415
- define i32 @xor_commutative6 (i32 %x , i32 %y , i32 % m ) {
433
+ define i32 @xor_commutative6 (i32 %x , i32 %m ) {
416
434
; CHECK-LABEL: @xor_commutative6(
435
+ ; CHECK-NEXT: [[Y:%.*]] = call i32 @gen32()
417
436
; CHECK-NEXT: [[AND:%.*]] = and i32 [[M:%.*]], [[X:%.*]]
418
437
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[M]], -1
419
- ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[NEG ]], [[Y:%.* ]]
438
+ ; CHECK-NEXT: [[AND1:%.*]] = and i32 [[Y ]], [[NEG ]]
420
439
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[AND1]], [[AND]]
421
440
; CHECK-NEXT: ret i32 [[XOR]]
422
441
;
442
+ %y = call i32 @gen32 ()
423
443
%and = and i32 %m , %x ; swapped order
424
444
%neg = xor i32 %m , -1
425
445
%and1 = and i32 %y , %neg ; swapped order
@@ -428,6 +448,7 @@ define i32 @xor_commutative6(i32 %x, i32 %y, i32 %m) {
428
448
}
429
449
430
450
451
+
431
452
define i32 @or_constmask_commutative (i32 %x , i32 %y ) {
432
453
; CHECK-LABEL: @or_constmask_commutative(
433
454
; CHECK-NEXT: [[AND:%.*]] = and i32 [[X:%.*]], 65280
0 commit comments