@@ -1528,10 +1528,12 @@ define <4 x i32> @PR41419(<4 x i32> %v) {
1528
1528
ret <4 x i32 > %s
1529
1529
}
1530
1530
1531
+ ; The shuffle masks in the next 4 tests are identical to make it easier
1532
+ ; to see that we are choosing the correct elements in the new shuffle.
1533
+
1531
1534
define <5 x i4 > @sel_common_op_commute0 (<5 x i4 > %x , <5 x i4 > %y ) {
1532
1535
; 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>
1536
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[X:%.*]], <5 x i4> [[Y:%.*]], <5 x i32> <i32 0, i32 6, i32 2, i32 3, i32 4>
1535
1537
; CHECK-NEXT: ret <5 x i4> [[S2]]
1536
1538
;
1537
1539
%s1 = shufflevector <5 x i4 > %x , <5 x i4 > %y , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
@@ -1541,8 +1543,7 @@ define <5 x i4> @sel_common_op_commute0(<5 x i4> %x, <5 x i4> %y) {
1541
1543
1542
1544
define <5 x i4 > @sel_common_op_commute1 (<5 x i4 > %x , <5 x i4 > %y ) {
1543
1545
; 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: [[S2:%.*]] = shufflevector <5 x i4> [[X:%.*]], <5 x i4> [[Y:%.*]], <5 x i32> <i32 0, i32 1, i32 7, i32 3, i32 4>
1546
1547
; CHECK-NEXT: ret <5 x i4> [[S2]]
1547
1548
;
1548
1549
%s1 = shufflevector <5 x i4 > %y , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
@@ -1552,8 +1553,7 @@ define <5 x i4> @sel_common_op_commute1(<5 x i4> %x, <5 x i4> %y) {
1552
1553
1553
1554
define <5 x i4 > @sel_common_op_commute2 (<5 x i4 > %x , <5 x i4 > %y ) {
1554
1555
; 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>
1556
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[X:%.*]], <5 x i4> [[Y:%.*]], <5 x i32> <i32 0, i32 1, i32 2, i32 3, i32 9>
1557
1557
; CHECK-NEXT: ret <5 x i4> [[S2]]
1558
1558
;
1559
1559
%s1 = shufflevector <5 x i4 > %x , <5 x i4 > %y , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
@@ -1563,8 +1563,7 @@ define <5 x i4> @sel_common_op_commute2(<5 x i4> %x, <5 x i4> %y) {
1563
1563
1564
1564
define <5 x i4 > @sel_common_op_commute3 (<5 x i4 > %x , <5 x i4 > %y ) {
1565
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>
1566
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[Y:%.*]], <5 x i4> [[X:%.*]], <5 x i32> <i32 0, i32 6, i32 7, i32 3, i32 9>
1568
1567
; CHECK-NEXT: ret <5 x i4> [[S2]]
1569
1568
;
1570
1569
%s1 = shufflevector <5 x i4 > %y , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 3 , i32 9 >
@@ -1574,15 +1573,16 @@ define <5 x i4> @sel_common_op_commute3(<5 x i4> %x, <5 x i4> %y) {
1574
1573
1575
1574
define <5 x i4 > @sel_common_op_commute3_poison_mask_elts (<5 x i4 > %x , <5 x i4 > %y ) {
1576
1575
; 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>
1576
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <5 x i4> [[Y:%.*]], <5 x i4> [[X:%.*]], <5 x i32> <i32 0, i32 6, i32 undef, i32 undef, i32 9>
1579
1577
; CHECK-NEXT: ret <5 x i4> [[S2]]
1580
1578
;
1581
1579
%s1 = shufflevector <5 x i4 > %y , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 2 , i32 poison, i32 9 >
1582
1580
%s2 = shufflevector <5 x i4 > %s1 , <5 x i4 > %x , <5 x i32 > <i32 0 , i32 6 , i32 poison, i32 3 , i32 4 >
1583
1581
ret <5 x i4 > %s2
1584
1582
}
1585
1583
1584
+ ; negative test - need shared operand
1585
+
1586
1586
define <5 x i4 > @sel_not_common_op_commute3 (<5 x i4 > %x , <5 x i4 > %y , <5 x i4 > %z ) {
1587
1587
; CHECK-LABEL: @sel_not_common_op_commute3(
1588
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>
@@ -1594,6 +1594,8 @@ define <5 x i4> @sel_not_common_op_commute3(<5 x i4> %x, <5 x i4> %y, <5 x i4> %
1594
1594
ret <5 x i4 > %s2
1595
1595
}
1596
1596
1597
+ ; negative test - need "select" shuffle, no lane changes
1598
+
1597
1599
define <5 x i4 > @not_sel_common_op (<5 x i4 > %x , <5 x i4 > %y ) {
1598
1600
; CHECK-LABEL: @not_sel_common_op(
1599
1601
; 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>
@@ -1605,11 +1607,13 @@ define <5 x i4> @not_sel_common_op(<5 x i4> %x, <5 x i4> %y) {
1605
1607
ret <5 x i4 > %s2
1606
1608
}
1607
1609
1610
+ ; extra use is ok
1611
+
1608
1612
define <4 x i32 > @sel_common_op_extra_use (<4 x i32 > %x , <4 x i32 > %y ) {
1609
1613
; CHECK-LABEL: @sel_common_op_extra_use(
1610
1614
; CHECK-NEXT: [[S1:%.*]] = shufflevector <4 x i32> [[Y:%.*]], <4 x i32> [[X:%.*]], <4 x i32> <i32 0, i32 5, i32 2, i32 7>
1611
1615
; 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>
1616
+ ; CHECK-NEXT: [[S2:%.*]] = shufflevector <4 x i32> [[Y ]], <4 x i32> [[X]], <4 x i32> <i32 0, i32 5 , i32 6, i32 7>
1613
1617
; CHECK-NEXT: ret <4 x i32> [[S2]]
1614
1618
;
1615
1619
%s1 = shufflevector <4 x i32 > %y , <4 x i32 > %x , <4 x i32 > <i32 0 , i32 5 , i32 2 , i32 7 >
0 commit comments