@@ -1468,9 +1468,52 @@ define <4 x i32> @splat_assoc_add(<4 x i32> %x, <4 x i32> %y) {
14681468 ret <4 x i32 > %r
14691469}
14701470
1471+ ; Undefs in splat mask are replaced with defined splat index
1472+
1473+ define <4 x i32 > @splat_assoc_add_undef_mask_elts (<4 x i32 > %x , <4 x i32 > %y ) {
1474+ ; CHECK-LABEL: @splat_assoc_add_undef_mask_elts(
1475+ ; CHECK-NEXT: [[TMP1:%.*]] = add <4 x i32> [[X:%.*]], <i32 42, i32 undef, i32 undef, i32 undef>
1476+ ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> undef, <4 x i32> zeroinitializer
1477+ ; CHECK-NEXT: [[R:%.*]] = add <4 x i32> [[TMP2]], [[Y:%.*]]
1478+ ; CHECK-NEXT: ret <4 x i32> [[R]]
1479+ ;
1480+ %splatx = shufflevector <4 x i32 > %x , <4 x i32 > undef , <4 x i32 > <i32 0 , i32 0 , i32 undef , i32 undef >
1481+ %a = add <4 x i32 > %y , <i32 42 , i32 42 , i32 42 , i32 42 >
1482+ %r = add <4 x i32 > %splatx , %a
1483+ ret <4 x i32 > %r
1484+ }
1485+
1486+ ; Undefs in splat mask are replaced with defined splat index
1487+
1488+ define <4 x i32 > @splat_assoc_add_undef_mask_elt_at_splat_index (<4 x i32 > %x , <4 x i32 > %y ) {
1489+ ; CHECK-LABEL: @splat_assoc_add_undef_mask_elt_at_splat_index(
1490+ ; CHECK-NEXT: [[TMP1:%.*]] = add <4 x i32> [[X:%.*]], <i32 42, i32 undef, i32 undef, i32 undef>
1491+ ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> undef, <4 x i32> zeroinitializer
1492+ ; CHECK-NEXT: [[R:%.*]] = add <4 x i32> [[TMP2]], [[Y:%.*]]
1493+ ; CHECK-NEXT: ret <4 x i32> [[R]]
1494+ ;
1495+ %splatx = shufflevector <4 x i32 > %x , <4 x i32 > undef , <4 x i32 > <i32 undef , i32 0 , i32 0 , i32 0 >
1496+ %a = add <4 x i32 > %y , <i32 42 , i32 42 , i32 42 , i32 42 >
1497+ %r = add <4 x i32 > %splatx , %a
1498+ ret <4 x i32 > %r
1499+ }
1500+
14711501define <4 x i32 > @splat_assoc_add_undef_constant_elts (<4 x i32 > %x , <4 x i32 > %y ) {
14721502; CHECK-LABEL: @splat_assoc_add_undef_constant_elts(
14731503; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> zeroinitializer
1504+ ; CHECK-NEXT: [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 42, i32 undef, i32 undef, i32 42>
1505+ ; CHECK-NEXT: [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]]
1506+ ; CHECK-NEXT: ret <4 x i32> [[R]]
1507+ ;
1508+ %splatx = shufflevector <4 x i32 > %x , <4 x i32 > undef , <4 x i32 > zeroinitializer
1509+ %a = add <4 x i32 > %y , <i32 42 , i32 undef , i32 undef , i32 42 >
1510+ %r = add <4 x i32 > %splatx , %a
1511+ ret <4 x i32 > %r
1512+ }
1513+
1514+ define <4 x i32 > @splat_assoc_add_undef_constant_elt_at_splat_index (<4 x i32 > %x , <4 x i32 > %y ) {
1515+ ; CHECK-LABEL: @splat_assoc_add_undef_constant_elt_at_splat_index(
1516+ ; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> zeroinitializer
14741517; CHECK-NEXT: [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 undef, i32 42, i32 undef, i32 42>
14751518; CHECK-NEXT: [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]]
14761519; CHECK-NEXT: ret <4 x i32> [[R]]
@@ -1481,6 +1524,45 @@ define <4 x i32> @splat_assoc_add_undef_constant_elts(<4 x i32> %x, <4 x i32> %y
14811524 ret <4 x i32 > %r
14821525}
14831526
1527+ define <4 x i32 > @splat_assoc_add_undef_mask_elts_undef_constant_elts (<4 x i32 > %x , <4 x i32 > %y ) {
1528+ ; CHECK-LABEL: @splat_assoc_add_undef_mask_elts_undef_constant_elts(
1529+ ; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 0, i32 undef, i32 0, i32 undef>
1530+ ; CHECK-NEXT: [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 42, i32 undef, i32 undef, i32 42>
1531+ ; CHECK-NEXT: [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]]
1532+ ; CHECK-NEXT: ret <4 x i32> [[R]]
1533+ ;
1534+ %splatx = shufflevector <4 x i32 > %x , <4 x i32 > undef , <4 x i32 > <i32 0 , i32 undef , i32 0 , i32 undef >
1535+ %a = add <4 x i32 > %y , <i32 42 , i32 undef , i32 undef , i32 42 >
1536+ %r = add <4 x i32 > %splatx , %a
1537+ ret <4 x i32 > %r
1538+ }
1539+
1540+ define <4 x i32 > @splat_assoc_add_undef_mask_elt_at_splat_index_undef_constant_elts (<4 x i32 > %x , <4 x i32 > %y ) {
1541+ ; CHECK-LABEL: @splat_assoc_add_undef_mask_elt_at_splat_index_undef_constant_elts(
1542+ ; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 undef, i32 0, i32 0, i32 0>
1543+ ; CHECK-NEXT: [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 42, i32 undef, i32 undef, i32 42>
1544+ ; CHECK-NEXT: [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]]
1545+ ; CHECK-NEXT: ret <4 x i32> [[R]]
1546+ ;
1547+ %splatx = shufflevector <4 x i32 > %x , <4 x i32 > undef , <4 x i32 > <i32 undef , i32 0 , i32 0 , i32 0 >
1548+ %a = add <4 x i32 > %y , <i32 42 , i32 undef , i32 undef , i32 42 >
1549+ %r = add <4 x i32 > %splatx , %a
1550+ ret <4 x i32 > %r
1551+ }
1552+
1553+ define <4 x i32 > @splat_assoc_add_undef_mask_elt_at_splat_index_undef_constant_elt_at_splat_index (<4 x i32 > %x , <4 x i32 > %y ) {
1554+ ; CHECK-LABEL: @splat_assoc_add_undef_mask_elt_at_splat_index_undef_constant_elt_at_splat_index(
1555+ ; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 undef, i32 0, i32 0, i32 0>
1556+ ; CHECK-NEXT: [[A:%.*]] = add <4 x i32> [[Y:%.*]], <i32 undef, i32 42, i32 undef, i32 42>
1557+ ; CHECK-NEXT: [[R:%.*]] = add <4 x i32> [[SPLATX]], [[A]]
1558+ ; CHECK-NEXT: ret <4 x i32> [[R]]
1559+ ;
1560+ %splatx = shufflevector <4 x i32 > %x , <4 x i32 > undef , <4 x i32 > <i32 undef , i32 0 , i32 0 , i32 0 >
1561+ %a = add <4 x i32 > %y , <i32 undef , i32 42 , i32 undef , i32 42 >
1562+ %r = add <4 x i32 > %splatx , %a
1563+ ret <4 x i32 > %r
1564+ }
1565+
14841566; Non-zero splat index; commute operands; FMF intersect
14851567
14861568define <2 x float > @splat_assoc_fmul (<2 x float > %x , <2 x float > %y ) {
@@ -1500,7 +1582,7 @@ define <2 x float> @splat_assoc_fmul(<2 x float> %x, <2 x float> %y) {
15001582
15011583define <3 x i8 > @splat_assoc_mul (<3 x i8 > %x , <3 x i8 > %y , <3 x i8 > %z ) {
15021584; CHECK-LABEL: @splat_assoc_mul(
1503- ; CHECK-NEXT: [[TMP1:%.*]] = mul <3 x i8> [[X :%.*]], [[Z :%.*]]
1585+ ; CHECK-NEXT: [[TMP1:%.*]] = mul <3 x i8> [[Z :%.*]], [[X :%.*]]
15041586; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <3 x i8> [[TMP1]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2>
15051587; CHECK-NEXT: [[R:%.*]] = mul <3 x i8> [[TMP2]], [[Y:%.*]]
15061588; CHECK-NEXT: ret <3 x i8> [[R]]
@@ -1512,15 +1594,58 @@ define <3 x i8> @splat_assoc_mul(<3 x i8> %x, <3 x i8> %y, <3 x i8> %z) {
15121594 ret <3 x i8 > %r
15131595}
15141596
1515- define <3 x i8 > @splat_assoc_mul_undef_elts (<3 x i8 > %x , <3 x i8 > %y , <3 x i8 > %z ) {
1516- ; CHECK-LABEL: @splat_assoc_mul_undef_elts(
1517- ; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <3 x i8> [[X:%.*]], <3 x i8> undef, <3 x i32> <i32 2, i32 undef, i32 2>
1597+ define <3 x i8 > @splat_assoc_mul_undef_elt1 (<3 x i8 > %x , <3 x i8 > %y , <3 x i8 > %z ) {
1598+ ; CHECK-LABEL: @splat_assoc_mul_undef_elt1(
1599+ ; CHECK-NEXT: [[TMP1:%.*]] = mul <3 x i8> [[Z:%.*]], [[X:%.*]]
1600+ ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <3 x i8> [[TMP1]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2>
1601+ ; CHECK-NEXT: [[R:%.*]] = mul <3 x i8> [[TMP2]], [[Y:%.*]]
1602+ ; CHECK-NEXT: ret <3 x i8> [[R]]
1603+ ;
1604+ %splatx = shufflevector <3 x i8 > %x , <3 x i8 > undef , <3 x i32 > <i32 undef , i32 2 , i32 2 >
1605+ %splatz = shufflevector <3 x i8 > %z , <3 x i8 > undef , <3 x i32 > <i32 2 , i32 2 , i32 2 >
1606+ %a = mul nsw <3 x i8 > %y , %splatz
1607+ %r = mul nsw nuw <3 x i8 > %a , %splatx
1608+ ret <3 x i8 > %r
1609+ }
1610+
1611+ define <3 x i8 > @splat_assoc_mul_undef_elt2 (<3 x i8 > %x , <3 x i8 > %y , <3 x i8 > %z ) {
1612+ ; CHECK-LABEL: @splat_assoc_mul_undef_elt2(
1613+ ; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <3 x i8> [[X:%.*]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2>
1614+ ; CHECK-NEXT: [[SPLATZ:%.*]] = shufflevector <3 x i8> [[Z:%.*]], <3 x i8> undef, <3 x i32> <i32 undef, i32 2, i32 2>
1615+ ; CHECK-NEXT: [[A:%.*]] = mul nsw <3 x i8> [[SPLATZ]], [[Y:%.*]]
1616+ ; CHECK-NEXT: [[R:%.*]] = mul nuw nsw <3 x i8> [[A]], [[SPLATX]]
1617+ ; CHECK-NEXT: ret <3 x i8> [[R]]
1618+ ;
1619+ %splatx = shufflevector <3 x i8 > %x , <3 x i8 > undef , <3 x i32 > <i32 2 , i32 2 , i32 2 >
1620+ %splatz = shufflevector <3 x i8 > %z , <3 x i8 > undef , <3 x i32 > <i32 undef , i32 2 , i32 2 >
1621+ %a = mul nsw <3 x i8 > %y , %splatz
1622+ %r = mul nsw nuw <3 x i8 > %a , %splatx
1623+ ret <3 x i8 > %r
1624+ }
1625+
1626+ define <3 x i8 > @splat_assoc_mul_undef_elt_at_splat_index1 (<3 x i8 > %x , <3 x i8 > %y , <3 x i8 > %z ) {
1627+ ; CHECK-LABEL: @splat_assoc_mul_undef_elt_at_splat_index1(
1628+ ; CHECK-NEXT: [[TMP1:%.*]] = mul <3 x i8> [[Z:%.*]], [[X:%.*]]
1629+ ; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <3 x i8> [[TMP1]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2>
1630+ ; CHECK-NEXT: [[R:%.*]] = mul <3 x i8> [[TMP2]], [[Y:%.*]]
1631+ ; CHECK-NEXT: ret <3 x i8> [[R]]
1632+ ;
1633+ %splatx = shufflevector <3 x i8 > %x , <3 x i8 > undef , <3 x i32 > <i32 2 , i32 2 , i32 undef >
1634+ %splatz = shufflevector <3 x i8 > %z , <3 x i8 > undef , <3 x i32 > <i32 2 , i32 2 , i32 2 >
1635+ %a = mul nsw <3 x i8 > %y , %splatz
1636+ %r = mul nsw nuw <3 x i8 > %a , %splatx
1637+ ret <3 x i8 > %r
1638+ }
1639+
1640+ define <3 x i8 > @splat_assoc_mul_undef_elt_at_splat_index2 (<3 x i8 > %x , <3 x i8 > %y , <3 x i8 > %z ) {
1641+ ; CHECK-LABEL: @splat_assoc_mul_undef_elt_at_splat_index2(
1642+ ; CHECK-NEXT: [[SPLATX:%.*]] = shufflevector <3 x i8> [[X:%.*]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 2>
15181643; CHECK-NEXT: [[SPLATZ:%.*]] = shufflevector <3 x i8> [[Z:%.*]], <3 x i8> undef, <3 x i32> <i32 2, i32 2, i32 undef>
15191644; CHECK-NEXT: [[A:%.*]] = mul nsw <3 x i8> [[SPLATZ]], [[Y:%.*]]
15201645; CHECK-NEXT: [[R:%.*]] = mul nuw nsw <3 x i8> [[A]], [[SPLATX]]
15211646; CHECK-NEXT: ret <3 x i8> [[R]]
15221647;
1523- %splatx = shufflevector <3 x i8 > %x , <3 x i8 > undef , <3 x i32 > <i32 2 , i32 undef , i32 2 >
1648+ %splatx = shufflevector <3 x i8 > %x , <3 x i8 > undef , <3 x i32 > <i32 2 , i32 2 , i32 2 >
15241649 %splatz = shufflevector <3 x i8 > %z , <3 x i8 > undef , <3 x i32 > <i32 2 , i32 2 , i32 undef >
15251650 %a = mul nsw <3 x i8 > %y , %splatz
15261651 %r = mul nsw nuw <3 x i8 > %a , %splatx
0 commit comments