[llvm] 68f267d - [InstCombine] add tests for udiv with common factor; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 08:35:33 PDT 2022
Author: Sanjay Patel
Date: 2022-10-07T11:35:17-04:00
New Revision: 68f267d2df4de9bb486683dc83551c7edb3dd9f1
URL: https://github.com/llvm/llvm-project/commit/68f267d2df4de9bb486683dc83551c7edb3dd9f1
DIFF: https://github.com/llvm/llvm-project/commit/68f267d2df4de9bb486683dc83551c7edb3dd9f1.diff
LOG: [InstCombine] add tests for udiv with common factor; NFC
Added:
Modified:
llvm/test/Transforms/InstCombine/div-shift.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/div-shift.ll b/llvm/test/Transforms/InstCombine/div-shift.ll
index 5982e73185c4..1251bd99619a 100644
--- a/llvm/test/Transforms/InstCombine/div-shift.ll
+++ b/llvm/test/Transforms/InstCombine/div-shift.ll
@@ -618,3 +618,115 @@ define i8 @udiv_shl_nuw_use(i8 %x, i8 %y, i8 %z) {
%d = udiv i8 %x, %s
ret i8 %d
}
+
+define i8 @udiv_lshr_mul_nuw(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_lshr_mul_nuw(
+; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[S:%.*]] = lshr i8 [[M]], [[Z:%.*]]
+; CHECK-NEXT: [[DIV:%.*]] = udiv i8 [[S]], [[X]]
+; CHECK-NEXT: ret i8 [[DIV]]
+;
+ %m = mul nuw i8 %x, %y
+ %s = lshr i8 %m, %z
+ %div = udiv i8 %s, %x
+ ret i8 %div
+}
+
+define <2 x i4> @udiv_lshr_mul_nuw_commute1(<2 x i4> %x, <2 x i4> %y, <2 x i4> %z) {
+; CHECK-LABEL: @udiv_lshr_mul_nuw_commute1(
+; CHECK-NEXT: [[M:%.*]] = mul nuw <2 x i4> [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT: [[S:%.*]] = lshr <2 x i4> [[M]], [[Z:%.*]]
+; CHECK-NEXT: [[DIV:%.*]] = udiv <2 x i4> [[S]], [[X]]
+; CHECK-NEXT: ret <2 x i4> [[DIV]]
+;
+ %m = mul nuw <2 x i4> %y, %x
+ %s = lshr <2 x i4> %m, %z
+ %div = udiv <2 x i4> %s, %x
+ ret <2 x i4> %div
+}
+
+define i8 @udiv_lshr_mul_nuw_commute2(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_lshr_mul_nuw_commute2(
+; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT: [[S:%.*]] = lshr i8 [[Z:%.*]], [[M]]
+; CHECK-NEXT: [[DIV:%.*]] = udiv i8 [[S]], [[X]]
+; CHECK-NEXT: ret i8 [[DIV]]
+;
+ %m = mul nuw i8 %y, %x
+ %s = lshr i8 %z, %m
+ %div = udiv i8 %s, %x
+ ret i8 %div
+}
+
+define i8 @udiv_lshr_mul_nuw_use1(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_lshr_mul_nuw_use1(
+; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: call void @use(i8 [[M]])
+; CHECK-NEXT: [[S:%.*]] = lshr i8 [[M]], [[Z:%.*]]
+; CHECK-NEXT: [[DIV:%.*]] = udiv i8 [[S]], [[X]]
+; CHECK-NEXT: ret i8 [[DIV]]
+;
+ %m = mul nuw i8 %x, %y
+ call void @use(i8 %m)
+ %s = lshr i8 %m, %z
+ %div = udiv i8 %s, %x
+ ret i8 %div
+}
+
+define i8 @udiv_lshr_mul_nuw_use2(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_lshr_mul_nuw_use2(
+; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[S:%.*]] = lshr i8 [[M]], [[Z:%.*]]
+; CHECK-NEXT: call void @use(i8 [[S]])
+; CHECK-NEXT: [[DIV:%.*]] = udiv i8 [[S]], [[X]]
+; CHECK-NEXT: ret i8 [[DIV]]
+;
+ %m = mul nuw i8 %x, %y
+ %s = lshr i8 %m, %z
+ call void @use(i8 %s)
+ %div = udiv i8 %s, %x
+ ret i8 %div
+}
+
+define i8 @udiv_lshr_mul_nuw_use3(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_lshr_mul_nuw_use3(
+; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: call void @use(i8 [[M]])
+; CHECK-NEXT: [[S:%.*]] = lshr i8 [[M]], [[Z:%.*]]
+; CHECK-NEXT: call void @use(i8 [[S]])
+; CHECK-NEXT: [[DIV:%.*]] = udiv i8 [[S]], [[X]]
+; CHECK-NEXT: ret i8 [[DIV]]
+;
+ %m = mul nuw i8 %x, %y
+ call void @use(i8 %m)
+ %s = lshr i8 %m, %z
+ call void @use(i8 %s)
+ %div = udiv i8 %s, %x
+ ret i8 %div
+}
+
+define i8 @udiv_lshr_mul_nsw(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @udiv_lshr_mul_nsw(
+; CHECK-NEXT: [[M:%.*]] = mul nsw i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[S:%.*]] = lshr i8 [[M]], [[Z:%.*]]
+; CHECK-NEXT: [[DIV:%.*]] = udiv i8 [[S]], [[X]]
+; CHECK-NEXT: ret i8 [[DIV]]
+;
+ %m = mul nsw i8 %x, %y
+ %s = lshr i8 %m, %z
+ %div = udiv i8 %s, %x
+ ret i8 %div
+}
+
+define i8 @sdiv_lshr_mul_nsw(i8 %x, i8 %y, i8 %z) {
+; CHECK-LABEL: @sdiv_lshr_mul_nsw(
+; CHECK-NEXT: [[M:%.*]] = mul nsw i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[S:%.*]] = lshr i8 [[M]], [[Z:%.*]]
+; CHECK-NEXT: [[DIV:%.*]] = sdiv i8 [[S]], [[X]]
+; CHECK-NEXT: ret i8 [[DIV]]
+;
+ %m = mul nsw i8 %x, %y
+ %s = lshr i8 %m, %z
+ %div = sdiv i8 %s, %x
+ ret i8 %div
+}
More information about the llvm-commits
mailing list