@@ -369,3 +369,110 @@ body: |
369
369
%1:_(<2 x s16>),%2:_(<2 x s16>) = G_UNMERGE_VALUES %0(s64)
370
370
$w0 = COPY %1(<2 x s16>)
371
371
...
372
+
373
+ # Transform unmerge(zext) into zext.
374
+ # In that test, the source of the zext is same size as the first definition
375
+ # of the unmerge. Therefore a we can just reuse the input of the zext for
376
+ # this definition.
377
+ ---
378
+ name : test_combine_unmerge_zext_to_zext_same_size
379
+ body : |
380
+ bb.1:
381
+ ; CHECK-LABEL: name: test_combine_unmerge_zext_to_zext_same_size
382
+ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
383
+ ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
384
+ ; CHECK: $w0 = COPY [[COPY]](s32)
385
+ ; CHECK: $w1 = COPY [[C]](s32)
386
+ %0:_(s32) = COPY $w0
387
+ %3:_(s64) = G_ZEXT %0(s32)
388
+ %1:_(s32),%2:_(s32) = G_UNMERGE_VALUES %3(s64)
389
+ $w0 = COPY %1(s32)
390
+ $w1 = COPY %2(s32)
391
+ ...
392
+
393
+ # Transform unmerge(zext) into zext.
394
+ # In that test, the source of the zext is smaller than the first definition
395
+ # of the unmerge. Therefore a G_ZEXT is required.
396
+ ---
397
+ name : test_combine_unmerge_zext_to_zext
398
+ body : |
399
+ bb.1:
400
+ ; CHECK-LABEL: name: test_combine_unmerge_zext_to_zext
401
+ ; CHECK: [[COPY:%[0-9]+]]:_(s8) = COPY $b0
402
+ ; CHECK: [[ZEXT:%[0-9]+]]:_(s16) = G_ZEXT [[COPY]](s8)
403
+ ; CHECK: [[C:%[0-9]+]]:_(s16) = G_CONSTANT i16 0
404
+ ; CHECK: $h0 = COPY [[ZEXT]](s16)
405
+ ; CHECK: $h1 = COPY [[C]](s16)
406
+ ; CHECK: $h2 = COPY [[C]](s16)
407
+ ; CHECK: $h3 = COPY [[C]](s16)
408
+ %0:_(s8) = COPY $b0
409
+ %3:_(s64) = G_ZEXT %0(s8)
410
+ %1:_(s16),%2:_(s16),%4:_(s16),%5:_(s16) = G_UNMERGE_VALUES %3(s64)
411
+ $h0 = COPY %1(s16)
412
+ $h1 = COPY %2(s16)
413
+ $h2 = COPY %4(s16)
414
+ $h3 = COPY %5(s16)
415
+ ...
416
+
417
+ # Check that we don't apply the unmerge(zext) to zext transformation
418
+ # when the first destination of the unmerge is smaller than the source
419
+ # of the zext.
420
+ ---
421
+ name : test_dont_combine_unmerge_zext_to_zext_src_bigger
422
+ body : |
423
+ bb.1:
424
+ ; CHECK-LABEL: name: test_dont_combine_unmerge_zext_to_zext_src_bigger
425
+ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
426
+ ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
427
+ ; CHECK: [[UV:%[0-9]+]]:_(s16), [[UV1:%[0-9]+]]:_(s16), [[UV2:%[0-9]+]]:_(s16), [[UV3:%[0-9]+]]:_(s16) = G_UNMERGE_VALUES [[ZEXT]](s64)
428
+ ; CHECK: $h0 = COPY [[UV]](s16)
429
+ ; CHECK: $h1 = COPY [[UV1]](s16)
430
+ ; CHECK: $h2 = COPY [[UV2]](s16)
431
+ ; CHECK: $h3 = COPY [[UV3]](s16)
432
+ %0:_(s32) = COPY $w0
433
+ %3:_(s64) = G_ZEXT %0(s32)
434
+ %1:_(s16),%2:_(s16),%4:_(s16),%5:_(s16) = G_UNMERGE_VALUES %3(s64)
435
+ $h0 = COPY %1(s16)
436
+ $h1 = COPY %2(s16)
437
+ $h2 = COPY %4(s16)
438
+ $h3 = COPY %5(s16)
439
+ ...
440
+
441
+ # Check that we don't apply the unmerge(zext) to zext transformation
442
+ # when the input zext deals with a vector type.
443
+ ---
444
+ name : test_dont_combine_unmerge_zext_to_zext_src_vector
445
+ body : |
446
+ bb.1:
447
+ ; CHECK-LABEL: name: test_dont_combine_unmerge_zext_to_zext_src_vector
448
+ ; CHECK: [[COPY:%[0-9]+]]:_(<2 x s16>) = COPY $w0
449
+ ; CHECK: [[ZEXT:%[0-9]+]]:_(<2 x s32>) = G_ZEXT [[COPY]](<2 x s16>)
450
+ ; CHECK: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[ZEXT]](<2 x s32>)
451
+ ; CHECK: $w0 = COPY [[UV]](s32)
452
+ ; CHECK: $w1 = COPY [[UV1]](s32)
453
+ %0:_(<2 x s16>) = COPY $w0
454
+ %3:_(<2 x s32>) = G_ZEXT %0(<2 x s16>)
455
+ %1:_(s32),%2:_(s32) = G_UNMERGE_VALUES %3(<2 x s32>)
456
+ $w0 = COPY %1(s32)
457
+ $w1 = COPY %2(s32)
458
+ ...
459
+
460
+ # Check that we don't apply the unmerge(zext) to zext transformation
461
+ # when the destination type is a vector type.
462
+ # We could actually handle this case but we would need to insert a cast.
463
+ ---
464
+ name : test_dont_combine_unmerge_zext_to_zext_dst_vector
465
+ body : |
466
+ bb.1:
467
+ ; CHECK-LABEL: name: test_dont_combine_unmerge_zext_to_zext_dst_vector
468
+ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
469
+ ; CHECK: [[ZEXT:%[0-9]+]]:_(s64) = G_ZEXT [[COPY]](s32)
470
+ ; CHECK: [[UV:%[0-9]+]]:_(<2 x s16>), [[UV1:%[0-9]+]]:_(<2 x s16>) = G_UNMERGE_VALUES [[ZEXT]](s64)
471
+ ; CHECK: $w0 = COPY [[UV]](<2 x s16>)
472
+ ; CHECK: $w1 = COPY [[UV1]](<2 x s16>)
473
+ %0:_(s32) = COPY $w0
474
+ %3:_(s64) = G_ZEXT %0(s32)
475
+ %1:_(<2 x s16>),%2:_(<2 x s16>) = G_UNMERGE_VALUES %3(s64)
476
+ $w0 = COPY %1(<2 x s16>)
477
+ $w1 = COPY %2(<2 x s16>)
478
+ ...
0 commit comments