[llvm] cb3bc9d - [InstSimplify] add more tests for rem-mul-div; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sun May 23 06:46:39 PDT 2021
Author: Sanjay Patel
Date: 2021-05-23T09:46:29-04:00
New Revision: cb3bc9d81d05724e85434665a2384a8dd812d74c
URL: https://github.com/llvm/llvm-project/commit/cb3bc9d81d05724e85434665a2384a8dd812d74c
DIFF: https://github.com/llvm/llvm-project/commit/cb3bc9d81d05724e85434665a2384a8dd812d74c.diff
LOG: [InstSimplify] add more tests for rem-mul-div; NFC
See D102864 for discussion.
Added:
Modified:
llvm/test/Transforms/InstSimplify/rem.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstSimplify/rem.ll b/llvm/test/Transforms/InstSimplify/rem.ll
index 32b04aaf746a9..5ee893a3e77c9 100644
--- a/llvm/test/Transforms/InstSimplify/rem.ll
+++ b/llvm/test/Transforms/InstSimplify/rem.ll
@@ -423,3 +423,55 @@ define i32 @urem_of_mul(i32 %x, i32 %y) {
%mod = urem i32 %mul, %y
ret i32 %mod
}
+
+define i4 @srem_mul_sdiv(i4 %x, i4 %y) {
+; CHECK-LABEL: @srem_mul_sdiv(
+; CHECK-NEXT: [[D:%.*]] = sdiv i4 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = mul i4 [[D]], [[Y]]
+; CHECK-NEXT: [[MOD:%.*]] = srem i4 [[MUL]], [[Y]]
+; CHECK-NEXT: ret i4 [[MOD]]
+;
+ %d = sdiv i4 %x, %y
+ %mul = mul i4 %d, %y
+ %mod = srem i4 %mul, %y
+ ret i4 %mod
+}
+
+define i8 @srem_mul_udiv(i8 %x, i8 %y) {
+; CHECK-LABEL: @srem_mul_udiv(
+; CHECK-NEXT: [[D:%.*]] = udiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[D]], [[Y]]
+; CHECK-NEXT: [[MOD:%.*]] = srem i8 [[MUL]], [[Y]]
+; CHECK-NEXT: ret i8 [[MOD]]
+;
+ %d = udiv i8 %x, %y
+ %mul = mul i8 %d, %y
+ %mod = srem i8 %mul, %y
+ ret i8 %mod
+}
+
+define <3 x i7> @urem_mul_udiv_vec_commuted(<3 x i7> %x, <3 x i7> %y) {
+; CHECK-LABEL: @urem_mul_udiv_vec_commuted(
+; CHECK-NEXT: [[D:%.*]] = udiv <3 x i7> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = mul <3 x i7> [[Y]], [[D]]
+; CHECK-NEXT: [[MOD:%.*]] = urem <3 x i7> [[MUL]], [[Y]]
+; CHECK-NEXT: ret <3 x i7> [[MOD]]
+;
+ %d = udiv <3 x i7> %x, %y
+ %mul = mul <3 x i7> %y, %d
+ %mod = urem <3 x i7> %mul, %y
+ ret <3 x i7> %mod
+}
+
+define i8 @urem_mul_sdiv(i8 %x, i8 %y) {
+; CHECK-LABEL: @urem_mul_sdiv(
+; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[Y]], [[D]]
+; CHECK-NEXT: [[MOD:%.*]] = urem i8 [[MUL]], [[Y]]
+; CHECK-NEXT: ret i8 [[MOD]]
+;
+ %d = sdiv i8 %x, %y
+ %mul = mul i8 %y, %d
+ %mod = urem i8 %mul, %y
+ ret i8 %mod
+}
More information about the llvm-commits
mailing list