@@ -1528,3 +1528,92 @@ define <4 x i32> @PR41419(<4 x i32> %v) {
1528
1528
ret <4 x i32 > %s
1529
1529
}
1530
1530
1531
+ define <5 x i4 > @sel_common_op_commute0 (<5 x i4 > %x , <5 x i4 > %y ) {
1532
+ ; CHECK-LABEL: @sel_common_op_commute0(
1533
+ ; CHECK-NEXT: [[S1:%.*]] = shufflevector <5 x i4> [[X:%.*]], <5 x i4> [[Y:%.*]], <5 x i32> <i32 undef, i32 6, i32 2, i32 undef, i32 undef>
1534
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[X]], <5 x i4> [[S1]], <5 x i32> <i32 0, i32 6, i32 7, i32 3, i32 4>
1535
+ ; CHECK-NEXT: ret <5 x i4> [[S2]]
1536
+ ;
1537
+ %s1 = shufflevector <5 x i4 > %x , <5 x i4 > %y , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
1538
+ %s2 = shufflevector <5 x i4 > %x , <5 x i4 > %s1 , <5 x i32 > <i32 0 , i32 6 , i32 7 , i32 3 , i32 4 >
1539
+ ret <5 x i4 > %s2
1540
+ }
1541
+
1542
+ define <5 x i4 > @sel_common_op_commute1 (<5 x i4 > %x , <5 x i4 > %y ) {
1543
+ ; CHECK-LABEL: @sel_common_op_commute1(
1544
+ ; CHECK-NEXT: [[S1:%.*]] = shufflevector <5 x i4> [[Y:%.*]], <5 x i4> [[X:%.*]], <5 x i32> <i32 undef, i32 6, i32 2, i32 undef, i32 undef>
1545
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[X]], <5 x i4> [[S1]], <5 x i32> <i32 0, i32 6, i32 7, i32 3, i32 4>
1546
+ ; CHECK-NEXT: ret <5 x i4> [[S2]]
1547
+ ;
1548
+ %s1 = shufflevector <5 x i4 > %y , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
1549
+ %s2 = shufflevector <5 x i4 > %x , <5 x i4 > %s1 , <5 x i32 > <i32 0 , i32 6 , i32 7 , i32 3 , i32 4 >
1550
+ ret <5 x i4 > %s2
1551
+ }
1552
+
1553
+ define <5 x i4 > @sel_common_op_commute2 (<5 x i4 > %x , <5 x i4 > %y ) {
1554
+ ; CHECK-LABEL: @sel_common_op_commute2(
1555
+ ; CHECK-NEXT: [[S1:%.*]] = shufflevector <5 x i4> [[X:%.*]], <5 x i4> [[Y:%.*]], <5 x i32> <i32 0, i32 undef, i32 undef, i32 3, i32 9>
1556
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[S1]], <5 x i4> [[X]], <5 x i32> <i32 0, i32 6, i32 7, i32 3, i32 4>
1557
+ ; CHECK-NEXT: ret <5 x i4> [[S2]]
1558
+ ;
1559
+ %s1 = shufflevector <5 x i4 > %x , <5 x i4 > %y , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
1560
+ %s2 = shufflevector <5 x i4 > %s1 , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 7 , i32 3 , i32 4 >
1561
+ ret <5 x i4 > %s2
1562
+ }
1563
+
1564
+ define <5 x i4 > @sel_common_op_commute3 (<5 x i4 > %x , <5 x i4 > %y ) {
1565
+ ; CHECK-LABEL: @sel_common_op_commute3(
1566
+ ; CHECK-NEXT: [[S1:%.*]] = shufflevector <5 x i4> [[Y:%.*]], <5 x i4> [[X:%.*]], <5 x i32> <i32 0, i32 undef, i32 undef, i32 3, i32 9>
1567
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[S1]], <5 x i4> [[X]], <5 x i32> <i32 0, i32 6, i32 7, i32 3, i32 4>
1568
+ ; CHECK-NEXT: ret <5 x i4> [[S2]]
1569
+ ;
1570
+ %s1 = shufflevector <5 x i4 > %y , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
1571
+ %s2 = shufflevector <5 x i4 > %s1 , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 7 , i32 3 , i32 4 >
1572
+ ret <5 x i4 > %s2
1573
+ }
1574
+
1575
+ define <5 x i4 > @sel_common_op_commute3_poison_mask_elts (<5 x i4 > %x , <5 x i4 > %y ) {
1576
+ ; CHECK-LABEL: @sel_common_op_commute3_poison_mask_elts(
1577
+ ; CHECK-NEXT: [[S1:%.*]] = shufflevector <5 x i4> [[Y:%.*]], <5 x i4> [[X:%.*]], <5 x i32> <i32 0, i32 undef, i32 undef, i32 undef, i32 9>
1578
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[S1]], <5 x i4> [[X]], <5 x i32> <i32 0, i32 6, i32 undef, i32 undef, i32 4>
1579
+ ; CHECK-NEXT: ret <5 x i4> [[S2]]
1580
+ ;
1581
+ %s1 = shufflevector <5 x i4 > %y , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 poison, i32 9 >
1582
+ %s2 = shufflevector <5 x i4 > %s1 , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 poison, i32 3 , i32 4 >
1583
+ ret <5 x i4 > %s2
1584
+ }
1585
+
1586
+ define <5 x i4 > @sel_not_common_op_commute3 (<5 x i4 > %x , <5 x i4 > %y , <5 x i4 > %z ) {
1587
+ ; CHECK-LABEL: @sel_not_common_op_commute3(
1588
+ ; CHECK-NEXT: [[S1:%.*]] = shufflevector <5 x i4> [[Y:%.*]], <5 x i4> [[Z:%.*]], <5 x i32> <i32 0, i32 undef, i32 undef, i32 3, i32 9>
1589
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[S1]], <5 x i4> [[X:%.*]], <5 x i32> <i32 0, i32 6, i32 7, i32 3, i32 4>
1590
+ ; CHECK-NEXT: ret <5 x i4> [[S2]]
1591
+ ;
1592
+ %s1 = shufflevector <5 x i4 > %y , <5 x i4 > %z , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
1593
+ %s2 = shufflevector <5 x i4 > %s1 , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 7 , i32 3 , i32 4 >
1594
+ ret <5 x i4 > %s2
1595
+ }
1596
+
1597
+ define <5 x i4 > @not_sel_common_op (<5 x i4 > %x , <5 x i4 > %y ) {
1598
+ ; CHECK-LABEL: @not_sel_common_op(
1599
+ ; CHECK-NEXT: [[S1:%.*]] = shufflevector <5 x i4> [[Y:%.*]], <5 x i4> [[X:%.*]], <5 x i32> <i32 undef, i32 6, i32 undef, i32 3, i32 9>
1600
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[S1]], <5 x i4> [[X]], <5 x i32> <i32 1, i32 6, i32 7, i32 3, i32 4>
1601
+ ; CHECK-NEXT: ret <5 x i4> [[S2]]
1602
+ ;
1603
+ %s1 = shufflevector <5 x i4 > %y , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
1604
+ %s2 = shufflevector <5 x i4 > %s1 , <5 x i4 > %x , <5 x i32 > <i32 1 , i32 6 , i32 7 , i32 3 , i32 4 >
1605
+ ret <5 x i4 > %s2
1606
+ }
1607
+
1608
+ define <4 x i32 > @sel_common_op_extra_use (<4 x i32 > %x , <4 x i32 > %y ) {
1609
+ ; CHECK-LABEL: @sel_common_op_extra_use(
1610
+ ; CHECK-NEXT: [[S1:%.*]] = shufflevector <4 x i32> [[Y:%.*]], <4 x i32> [[X:%.*]], <4 x i32> <i32 0, i32 5, i32 2, i32 7>
1611
+ ; CHECK-NEXT: call void @use_v4i32(<4 x i32> [[S1]])
1612
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <4 x i32> [[S1]], <4 x i32> [[X]], <4 x i32> <i32 0, i32 1, i32 6, i32 7>
1613
+ ; CHECK-NEXT: ret <4 x i32> [[S2]]
1614
+ ;
1615
+ %s1 = shufflevector <4 x i32 > %y , <4 x i32 > %x , <4 x i32 > <i32 0 , i32 5 , i32 2 , i32 7 >
1616
+ call void @use_v4i32 (<4 x i32 > %s1 )
1617
+ %s2 = shufflevector <4 x i32 > %s1 , <4 x i32 > %x , <4 x i32 > <i32 0 , i32 1 , i32 6 , i32 7 >
1618
+ ret <4 x i32 > %s2
1619
+ }
0 commit comments