[llvm] 4376afe - [InstCombine] add tests for mul+sub common factor; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 24 08:33:27 PDT 2022
Author: Sanjay Patel
Date: 2022-08-24T11:31:18-04:00
New Revision: 4376afe727b2dc4737f1471517cbb7a3b5b9add9
URL: https://github.com/llvm/llvm-project/commit/4376afe727b2dc4737f1471517cbb7a3b5b9add9
DIFF: https://github.com/llvm/llvm-project/commit/4376afe727b2dc4737f1471517cbb7a3b5b9add9.diff
LOG: [InstCombine] add tests for mul+sub common factor; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/sub.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/sub.ll b/llvm/test/Transforms/InstCombine/sub.ll
index fa243dffb1cc..871489fd13e8 100644
--- a/llvm/test/Transforms/InstCombine/sub.ll
+++ b/llvm/test/Transforms/InstCombine/sub.ll
@@ -2002,3 +2002,60 @@ define i16 @urem_zext_noundef(i8 noundef %x, i8 %y) {
%z = sub i16 %ex, %ed
ret i16 %z
}
+
+define i8 @mul_sub_common_factor_commute1(i8 %x, i8 %y) {
+; CHECK-LABEL: @mul_sub_common_factor_commute1(
+; CHECK-NEXT: [[M:%.*]] = mul nsw i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[A:%.*]] = sub nsw i8 [[M]], [[X]]
+; CHECK-NEXT: ret i8 [[A]]
+;
+ %m = mul nsw i8 %x, %y
+ %a = sub nsw i8 %m, %x
+ ret i8 %a
+}
+
+define <2 x i8> @mul_sub_common_factor_commute2(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @mul_sub_common_factor_commute2(
+; CHECK-NEXT: [[M:%.*]] = mul nuw <2 x i8> [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT: [[A:%.*]] = sub nuw <2 x i8> [[M]], [[X]]
+; CHECK-NEXT: ret <2 x i8> [[A]]
+;
+ %m = mul nuw <2 x i8> %y, %x
+ %a = sub nuw <2 x i8> %m, %x
+ ret <2 x i8> %a
+}
+
+define i8 @mul_sub_common_factor_commute3(i8 %x, i8 %y) {
+; CHECK-LABEL: @mul_sub_common_factor_commute3(
+; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[A:%.*]] = sub nsw i8 [[X]], [[M]]
+; CHECK-NEXT: ret i8 [[A]]
+;
+ %m = mul nuw i8 %x, %y
+ %a = sub nsw i8 %x, %m
+ ret i8 %a
+}
+
+define i8 @mul_sub_common_factor_commute4(i8 %x, i8 %y) {
+; CHECK-LABEL: @mul_sub_common_factor_commute4(
+; CHECK-NEXT: [[M:%.*]] = mul nsw i8 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT: [[A:%.*]] = sub nuw i8 [[X]], [[M]]
+; CHECK-NEXT: ret i8 [[A]]
+;
+ %m = mul nsw i8 %y, %x
+ %a = sub nuw i8 %x, %m
+ ret i8 %a
+}
+
+define i8 @mul_sub_common_factor_use(i8 %x, i8 %y) {
+; CHECK-LABEL: @mul_sub_common_factor_use(
+; CHECK-NEXT: [[M:%.*]] = mul i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: call void @use8(i8 [[M]])
+; CHECK-NEXT: [[A:%.*]] = sub i8 [[M]], [[X]]
+; CHECK-NEXT: ret i8 [[A]]
+;
+ %m = mul i8 %x, %y
+ call void @use8(i8 %m)
+ %a = sub i8 %m, %x
+ ret i8 %a
+}
More information about the llvm-commits
mailing list