[llvm] 19fc5e8 - [InstCombine] Add test cases for `(rem (shl Y, X), (shl Z, X))`; NFC

Noah Goldstein via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 6 12:46:54 PDT 2023


Author: Noah Goldstein
Date: 2023-07-06T14:46:34-05:00
New Revision: 19fc5e8208b6c3e42e0559c353803e6d6b7ade19

URL: https://github.com/llvm/llvm-project/commit/19fc5e8208b6c3e42e0559c353803e6d6b7ade19
DIFF: https://github.com/llvm/llvm-project/commit/19fc5e8208b6c3e42e0559c353803e6d6b7ade19.diff

LOG: [InstCombine] Add test cases for `(rem (shl Y, X), (shl Z, X))`; NFC

Differential Revision: https://reviews.llvm.org/D147107

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/rem-mul-shl.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/rem-mul-shl.ll b/llvm/test/Transforms/InstCombine/rem-mul-shl.ll
index b6b81aa5981395..52cfd302064f8a 100644
--- a/llvm/test/Transforms/InstCombine/rem-mul-shl.ll
+++ b/llvm/test/Transforms/InstCombine/rem-mul-shl.ll
@@ -49,6 +49,19 @@ define i8 @urem_XY_XZ_with_CY_rem_CZ_eq_0(i8 %X) {
   ret i8 %r
 }
 
+define i8 @urem_XY_XZ_with_CY_rem_CZ_eq_0_with_shl(i8 %X) {
+; CHECK-LABEL: @urem_XY_XZ_with_CY_rem_CZ_eq_0_with_shl(
+; CHECK-NEXT:    [[BO0:%.*]] = shl nuw i8 15, [[X:%.*]]
+; CHECK-NEXT:    [[BO1:%.*]] = shl i8 5, [[X]]
+; CHECK-NEXT:    [[R:%.*]] = urem i8 [[BO0]], [[BO1]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %BO0 = shl nuw i8 15, %X
+  %BO1 = shl i8 5, %X
+  %r = urem i8 %BO0, %BO1
+  ret i8 %r
+}
+
 define i8 @urem_XY_XZ_with_CY_rem_CZ_eq_0_fail_missing_flag(i8 %X) {
 ; CHECK-LABEL: @urem_XY_XZ_with_CY_rem_CZ_eq_0_fail_missing_flag(
 ; CHECK-NEXT:    [[BO0:%.*]] = mul nsw i8 [[X:%.*]], 15
@@ -73,6 +86,19 @@ define i8 @urem_XY_XZ_with_CY_lt_CZ(i8 %X) {
   ret i8 %r
 }
 
+define i8 @urem_XY_XZ_with_CY_lt_CZ_with_shl(i8 %X) {
+; CHECK-LABEL: @urem_XY_XZ_with_CY_lt_CZ_with_shl(
+; CHECK-NEXT:    [[BO0:%.*]] = shl i8 3, [[X:%.*]]
+; CHECK-NEXT:    [[BO1:%.*]] = shl nuw i8 12, [[X]]
+; CHECK-NEXT:    [[R:%.*]] = urem i8 [[BO0]], [[BO1]]
+; CHECK-NEXT:    ret i8 [[R]]
+;
+  %BO0 = shl i8 3, %X
+  %BO1 = shl nuw i8 12, %X
+  %r = urem i8 %BO0, %BO1
+  ret i8 %r
+}
+
 define <2 x i8> @urem_XY_XZ_with_CY_lt_CZ_with_nsw_out(<2 x i8> %X) {
 ; CHECK-LABEL: @urem_XY_XZ_with_CY_lt_CZ_with_nsw_out(
 ; CHECK-NEXT:    [[R:%.*]] = shl nuw nsw <2 x i8> [[X:%.*]], <i8 2, i8 2>
@@ -281,6 +307,19 @@ define i8 @srem_XY_XZ_with_CY_lt_CZ_with_nuw_out(i8 %X) {
   ret i8 %r
 }
 
+define <2 x i8> @srem_XY_XZ_with_CY_lt_CZ_with_nuw_out_with_shl(<2 x i8> %X) {
+; CHECK-LABEL: @srem_XY_XZ_with_CY_lt_CZ_with_nuw_out_with_shl(
+; CHECK-NEXT:    [[BO0:%.*]] = shl nuw <2 x i8> <i8 3, i8 3>, [[X:%.*]]
+; CHECK-NEXT:    [[BO1:%.*]] = shl nsw <2 x i8> <i8 15, i8 15>, [[X]]
+; CHECK-NEXT:    [[R:%.*]] = srem <2 x i8> [[BO0]], [[BO1]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %BO0 = shl nuw <2 x i8> <i8 3, i8 3>, %X
+  %BO1 = shl nsw <2 x i8> <i8 15, i8 15>, %X
+  %r = srem <2 x i8> %BO0, %BO1
+  ret <2 x i8> %r
+}
+
 define i8 @srem_XY_XZ_with_CY_lt_CZ_no_nsw_out(i8 %X) {
 ; CHECK-LABEL: @srem_XY_XZ_with_CY_lt_CZ_no_nsw_out(
 ; CHECK-NEXT:    [[R:%.*]] = mul nsw i8 [[X:%.*]], 5


        


More information about the llvm-commits mailing list