Skip to content

Commit 7dffc52

Browse files
committed
[InstCombine] Pre-commit tests (NFC)
1 parent 0016216 commit 7dffc52

File tree

1 file changed

+72
-1
lines changed
  • llvm/test/Transforms/InstCombine

1 file changed

+72
-1
lines changed

llvm/test/Transforms/InstCombine/mul.ll

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,31 @@ define i32 @combine_mul_nabs_i32(i32 %0) {
16051605
ret i32 %m
16061606
}
16071607

1608+
define i32 @combine_mul_nabs_i32_unsigned_wrap(i32 %0) {
1609+
; CHECK-LABEL: @combine_mul_nabs_i32_unsigned_wrap(
1610+
; CHECK-NEXT: [[M:%.*]] = mul i32 [[TMP0:%.*]], [[TMP0]]
1611+
; CHECK-NEXT: ret i32 [[M]]
1612+
;
1613+
%c = icmp slt i32 %0, 0
1614+
%s = sub nsw i32 0, %0
1615+
%r = select i1 %c, i32 %0, i32 %s
1616+
%m = mul nuw i32 %r, %r
1617+
ret i32 %m
1618+
}
1619+
1620+
define i32 @combine_mul_nabs_i32_signed_wrap(i32 %0) {
1621+
; CHECK-LABEL: @combine_mul_nabs_i32_signed_wrap(
1622+
; CHECK-NEXT: [[M:%.*]] = mul i32 [[TMP0:%.*]], [[TMP0]]
1623+
; CHECK-NEXT: ret i32 [[M]]
1624+
;
1625+
%c = icmp slt i32 %0, 0
1626+
%s = sub nsw i32 0, %0
1627+
%r = select i1 %c, i32 %0, i32 %s
1628+
%m = mul nsw i32 %r, %r
1629+
ret i32 %m
1630+
}
1631+
1632+
16081633
define <4 x i32> @combine_mul_nabs_v4i32(<4 x i32> %0) {
16091634
; CHECK-LABEL: @combine_mul_nabs_v4i32(
16101635
; CHECK-NEXT: [[M:%.*]] = mul <4 x i32> [[TMP0:%.*]], [[TMP0]]
@@ -1617,13 +1642,37 @@ define <4 x i32> @combine_mul_nabs_v4i32(<4 x i32> %0) {
16171642
ret <4 x i32> %m
16181643
}
16191644

1645+
define <4 x i32> @combine_mul_nabs_v4i32_unsigned_wrap(<4 x i32> %0) {
1646+
; CHECK-LABEL: @combine_mul_nabs_v4i32_unsigned_wrap(
1647+
; CHECK-NEXT: [[M:%.*]] = mul <4 x i32> [[TMP0:%.*]], [[TMP0]]
1648+
; CHECK-NEXT: ret <4 x i32> [[M]]
1649+
;
1650+
%c = icmp slt <4 x i32> %0, zeroinitializer
1651+
%s = sub nsw <4 x i32> zeroinitializer, %0
1652+
%r = select <4 x i1> %c, <4 x i32> %0, <4 x i32> %s
1653+
%m = mul nuw <4 x i32> %r, %r
1654+
ret <4 x i32> %m
1655+
}
1656+
1657+
define <4 x i32> @combine_mul_nabs_v4i32_signed_wrap(<4 x i32> %0) {
1658+
; CHECK-LABEL: @combine_mul_nabs_v4i32_signed_wrap(
1659+
; CHECK-NEXT: [[M:%.*]] = mul <4 x i32> [[TMP0:%.*]], [[TMP0]]
1660+
; CHECK-NEXT: ret <4 x i32> [[M]]
1661+
;
1662+
%c = icmp slt <4 x i32> %0, zeroinitializer
1663+
%s = sub nsw <4 x i32> zeroinitializer, %0
1664+
%r = select <4 x i1> %c, <4 x i32> %0, <4 x i32> %s
1665+
%m = mul nsw <4 x i32> %r, %r
1666+
ret <4 x i32> %m
1667+
}
1668+
16201669
define i32 @combine_mul_abs_intrin(i32 %x) {
16211670
; CHECK-LABEL: @combine_mul_abs_intrin(
16221671
; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[X]]
16231672
; CHECK-NEXT: ret i32 [[MUL]]
16241673
;
16251674
%abs = call i32 @llvm.abs.i32(i32 %x, i1 false)
1626-
%mul = mul i32 %abs, %abs
1675+
%mul = mul nuw i32 %abs, %abs
16271676
ret i32 %mul
16281677
}
16291678

@@ -1638,6 +1687,28 @@ define i32 @combine_mul_nabs_intrin(i32 %x) {
16381687
ret i32 %mul
16391688
}
16401689

1690+
define i32 @combine_mul_nabs_intrin_unsigned_flags(i32 %x) {
1691+
; CHECK-LABEL: @combine_mul_nabs_intrin_unsigned_flags(
1692+
; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[X]]
1693+
; CHECK-NEXT: ret i32 [[MUL]]
1694+
;
1695+
%abs = call i32 @llvm.abs.i32(i32 %x, i1 false)
1696+
%neg = sub i32 0, %abs
1697+
%mul = mul nuw i32 %neg, %neg
1698+
ret i32 %mul
1699+
}
1700+
1701+
define i32 @combine_mul_nabs_intrin_signed_flags(i32 %x) {
1702+
; CHECK-LABEL: @combine_mul_nabs_intrin_signed_flags(
1703+
; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[X]]
1704+
; CHECK-NEXT: ret i32 [[MUL]]
1705+
;
1706+
%abs = call i32 @llvm.abs.i32(i32 %x, i1 false)
1707+
%neg = sub i32 0, %abs
1708+
%mul = mul nsw i32 %neg, %neg
1709+
ret i32 %mul
1710+
}
1711+
16411712
; z * splat(0) = splat(0), even for scalable vectors
16421713
define <vscale x 2 x i64> @mul_scalable_splat_zero(<vscale x 2 x i64> %z) {
16431714
; CHECK-LABEL: @mul_scalable_splat_zero(

0 commit comments

Comments
 (0)