Skip to content

Commit 08bfac7

Browse files
committed
[InstCombine] Pre-commit tests (NFC)
1 parent b8d0cba commit 08bfac7

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed

llvm/test/Transforms/InstCombine/mul-inseltpoison.ll

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,26 @@ define i32 @combine_mul_abs_intrin(i32 %x) {
915915
ret i32 %mul
916916
}
917917

918+
define i32 @combine_mul_abs_intrin_nuw(i32 %x) {
919+
; CHECK-LABEL: @combine_mul_abs_intrin_nuw(
920+
; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[X]]
921+
; CHECK-NEXT: ret i32 [[MUL]]
922+
;
923+
%abs = call i32 @llvm.abs.i32(i32 %x, i1 false)
924+
%mul = mul nuw i32 %abs, %abs
925+
ret i32 %mul
926+
}
927+
928+
define i32 @combine_mul_abs_intrin_nsw(i32 %x) {
929+
; CHECK-LABEL: @combine_mul_abs_intrin_nsw(
930+
; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[X]]
931+
; CHECK-NEXT: ret i32 [[MUL]]
932+
;
933+
%abs = call i32 @llvm.abs.i32(i32 %x, i1 false)
934+
%mul = mul nsw i32 %abs, %abs
935+
ret i32 %mul
936+
}
937+
918938
define i32 @combine_mul_nabs_intrin(i32 %x) {
919939
; CHECK-LABEL: @combine_mul_nabs_intrin(
920940
; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[X]]
@@ -926,6 +946,29 @@ define i32 @combine_mul_nabs_intrin(i32 %x) {
926946
ret i32 %mul
927947
}
928948

949+
define i32 @combine_mul_nabs_intrin_nuw(i32 %x) {
950+
; CHECK-LABEL: @combine_mul_nabs_intrin_nuw(
951+
; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[X]]
952+
; CHECK-NEXT: ret i32 [[MUL]]
953+
;
954+
%abs = call i32 @llvm.abs.i32(i32 %x, i1 false)
955+
%neg = sub i32 0, %abs
956+
%mul = mul nuw i32 %neg, %neg
957+
ret i32 %mul
958+
}
959+
960+
define i32 @combine_mul_nabs_intrin_nsw(i32 %x) {
961+
; CHECK-LABEL: @combine_mul_nabs_intrin_nsw(
962+
; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], [[X]]
963+
; CHECK-NEXT: ret i32 [[MUL]]
964+
;
965+
%abs = call i32 @llvm.abs.i32(i32 %x, i1 false)
966+
%neg = sub i32 0, %abs
967+
%mul = mul nsw i32 %neg, %neg
968+
ret i32 %mul
969+
}
970+
971+
929972
; z * splat(0) = splat(0), even for scalable vectors
930973
define <vscale x 2 x i64> @mul_scalable_splat_zero(<vscale x 2 x i64> %z) {
931974
; CHECK-LABEL: @mul_scalable_splat_zero(

llvm/test/Transforms/InstCombine/mul.ll

Lines changed: 71 additions & 0 deletions
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,6 +1642,30 @@ 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]]
@@ -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)