[llvm] 4b48cdd - [InstCombine] add tests for rem with select operand; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 7 08:10:12 PST 2021


Author: Sanjay Patel
Date: 2021-12-07T11:08:26-05:00
New Revision: 4b48cdd4dd47ca008f2efd74f3f56214fc36497a

URL: https://github.com/llvm/llvm-project/commit/4b48cdd4dd47ca008f2efd74f3f56214fc36497a
DIFF: https://github.com/llvm/llvm-project/commit/4b48cdd4dd47ca008f2efd74f3f56214fc36497a.diff

LOG: [InstCombine] add tests for rem with select operand; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/rem.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/rem.ll b/llvm/test/Transforms/InstCombine/rem.ll
index 2a75984b22314..468ccb261d2fc 100644
--- a/llvm/test/Transforms/InstCombine/rem.ll
+++ b/llvm/test/Transforms/InstCombine/rem.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt < %s -instcombine -S | FileCheck %s
 
+declare void @use(i32)
+
 define i64 @rem_signed(i64 %x1, i64 %y2) {
 ; CHECK-LABEL: @rem_signed(
 ; CHECK-NEXT:    [[TMP1:%.*]] = srem i64 [[X1:%.*]], [[Y2:%.*]]
@@ -773,3 +775,178 @@ define double @PR34870(i1 %cond, double %x, double %y) {
   ret double %fmod
 }
 
+define i32 @srem_constant_dividend_select_of_constants_divisor(i1 %b) {
+; CHECK-LABEL: @srem_constant_dividend_select_of_constants_divisor(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 12, i32 -3
+; CHECK-NEXT:    [[R:%.*]] = srem i32 42, [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 12, i32 -3
+  %r = srem i32 42, %s
+  ret i32 %r
+}
+
+define i32 @srem_constant_dividend_select_of_constants_divisor_use(i1 %b) {
+; CHECK-LABEL: @srem_constant_dividend_select_of_constants_divisor_use(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 12, i32 -3
+; CHECK-NEXT:    call void @use(i32 [[S]])
+; CHECK-NEXT:    [[R:%.*]] = srem i32 42, [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 12, i32 -3
+  call void @use(i32 %s)
+  %r = srem i32 42, %s
+  ret i32 %r
+}
+
+define i32 @srem_constant_dividend_select_divisor1(i1 %b, i32 %x) {
+; CHECK-LABEL: @srem_constant_dividend_select_divisor1(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 [[X:%.*]], i32 -3
+; CHECK-NEXT:    [[R:%.*]] = srem i32 42, [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 %x, i32 -3
+  %r = srem i32 42, %s
+  ret i32 %r
+}
+
+define i32 @srem_constant_dividend_select_divisor2(i1 %b, i32 %x) {
+; CHECK-LABEL: @srem_constant_dividend_select_divisor2(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 12, i32 [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = srem i32 42, [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 12, i32 %x
+  %r = srem i32 42, %s
+  ret i32 %r
+}
+
+define <2 x i8> @srem_constant_dividend_select_of_constants_divisor_vec(i1 %b) {
+; CHECK-LABEL: @srem_constant_dividend_select_of_constants_divisor_vec(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 4>
+; CHECK-NEXT:    [[R:%.*]] = srem <2 x i8> <i8 42, i8 -42>, [[S]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %s = select i1 %b, <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 4>
+  %r = srem <2 x i8> <i8 42, i8 -42>, %s
+  ret <2 x i8> %r
+}
+
+define <2 x i8> @srem_constant_dividend_select_of_constants_divisor_vec_ub1(i1 %b) {
+; CHECK-LABEL: @srem_constant_dividend_select_of_constants_divisor_vec_ub1(
+; CHECK-NEXT:    ret <2 x i8> <i8 2, i8 -2>
+;
+  %s = select i1 %b, <2 x i8> <i8 0, i8 -5>, <2 x i8> <i8 -4, i8 4>
+  %r = srem <2 x i8> <i8 42, i8 -42>, %s
+  ret <2 x i8> %r
+}
+
+define <2 x i8> @srem_constant_dividend_select_of_constants_divisor_vec_ub2(i1 %b) {
+; CHECK-LABEL: @srem_constant_dividend_select_of_constants_divisor_vec_ub2(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 -1>
+; CHECK-NEXT:    [[R:%.*]] = srem <2 x i8> <i8 42, i8 -128>, [[S]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %s = select i1 %b, <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 -1>
+  %r = srem <2 x i8> <i8 42, i8 -128>, %s
+  ret <2 x i8> %r
+}
+
+define i32 @srem_select_of_constants_divisor(i1 %b, i32 %x) {
+; CHECK-LABEL: @srem_select_of_constants_divisor(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 12, i32 -3
+; CHECK-NEXT:    [[R:%.*]] = srem i32 [[X:%.*]], [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 12, i32 -3
+  %r = srem i32 %x, %s
+  ret i32 %r
+}
+
+define i32 @urem_constant_dividend_select_of_constants_divisor(i1 %b) {
+; CHECK-LABEL: @urem_constant_dividend_select_of_constants_divisor(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 12, i32 -3
+; CHECK-NEXT:    [[R:%.*]] = urem i32 42, [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 12, i32 -3
+  %r = urem i32 42, %s
+  ret i32 %r
+}
+
+define i32 @urem_constant_dividend_select_of_constants_divisor_use(i1 %b) {
+; CHECK-LABEL: @urem_constant_dividend_select_of_constants_divisor_use(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 12, i32 -3
+; CHECK-NEXT:    call void @use(i32 [[S]])
+; CHECK-NEXT:    [[R:%.*]] = urem i32 42, [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 12, i32 -3
+  call void @use(i32 %s)
+  %r = urem i32 42, %s
+  ret i32 %r
+}
+
+define i32 @urem_constant_dividend_select_divisor1(i1 %b, i32 %x) {
+; CHECK-LABEL: @urem_constant_dividend_select_divisor1(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 [[X:%.*]], i32 -3
+; CHECK-NEXT:    [[R:%.*]] = urem i32 42, [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 %x, i32 -3
+  %r = urem i32 42, %s
+  ret i32 %r
+}
+
+define i32 @urem_constant_dividend_select_divisor2(i1 %b, i32 %x) {
+; CHECK-LABEL: @urem_constant_dividend_select_divisor2(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 12, i32 [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = urem i32 42, [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 12, i32 %x
+  %r = urem i32 42, %s
+  ret i32 %r
+}
+
+define <2 x i8> @urem_constant_dividend_select_of_constants_divisor_vec(i1 %b) {
+; CHECK-LABEL: @urem_constant_dividend_select_of_constants_divisor_vec(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 4>
+; CHECK-NEXT:    [[R:%.*]] = urem <2 x i8> <i8 42, i8 -42>, [[S]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %s = select i1 %b, <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 4>
+  %r = urem <2 x i8> <i8 42, i8 -42>, %s
+  ret <2 x i8> %r
+}
+
+define <2 x i8> @urem_constant_dividend_select_of_constants_divisor_vec_ub1(i1 %b) {
+; CHECK-LABEL: @urem_constant_dividend_select_of_constants_divisor_vec_ub1(
+; CHECK-NEXT:    ret <2 x i8> <i8 42, i8 2>
+;
+  %s = select i1 %b, <2 x i8> <i8 0, i8 -5>, <2 x i8> <i8 -4, i8 4>
+  %r = urem <2 x i8> <i8 42, i8 -42>, %s
+  ret <2 x i8> %r
+}
+
+define <2 x i8> @urem_constant_dividend_select_of_constants_divisor_vec_ub2(i1 %b) {
+; CHECK-LABEL: @urem_constant_dividend_select_of_constants_divisor_vec_ub2(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 -1>
+; CHECK-NEXT:    [[R:%.*]] = urem <2 x i8> <i8 42, i8 -128>, [[S]]
+; CHECK-NEXT:    ret <2 x i8> [[R]]
+;
+  %s = select i1 %b, <2 x i8> <i8 12, i8 -5>, <2 x i8> <i8 -4, i8 -1>
+  %r = urem <2 x i8> <i8 42, i8 -128>, %s
+  ret <2 x i8> %r
+}
+
+define i32 @urem_select_of_constants_divisor(i1 %b, i32 %x) {
+; CHECK-LABEL: @urem_select_of_constants_divisor(
+; CHECK-NEXT:    [[S:%.*]] = select i1 [[B:%.*]], i32 12, i32 -3
+; CHECK-NEXT:    [[R:%.*]] = urem i32 [[X:%.*]], [[S]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = select i1 %b, i32 12, i32 -3
+  %r = urem i32 %x, %s
+  ret i32 %r
+}


        


More information about the llvm-commits mailing list