[llvm] 9555d1e - [InstCombine] add/adjust tests for min/max intrinsics; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 19 07:10:50 PDT 2021


Author: Sanjay Patel
Date: 2021-09-19T10:10:37-04:00
New Revision: 9555d1edb0d16f135ae57695fc2da55deaabf082

URL: https://github.com/llvm/llvm-project/commit/9555d1edb0d16f135ae57695fc2da55deaabf082
DIFF: https://github.com/llvm/llvm-project/commit/9555d1edb0d16f135ae57695fc2da55deaabf082.diff

LOG: [InstCombine] add/adjust tests for min/max intrinsics; NFC

If we transform these, we have to propagate no-wrap/undef carefully.

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/minmax-intrinsics.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll b/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
index d0d65f881d912..b84eee089a434 100644
--- a/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
+++ b/llvm/test/Transforms/InstCombine/minmax-intrinsics.ll
@@ -1924,11 +1924,11 @@ define i8 @smax_offset_uses(i8 %x) {
 
 define <3 x i8> @smin_offset(<3 x i8> %x) {
 ; CHECK-LABEL: @smin_offset(
-; CHECK-NEXT:    [[A:%.*]] = add nsw <3 x i8> [[X:%.*]], <i8 124, i8 124, i8 124>
+; CHECK-NEXT:    [[A:%.*]] = add nuw nsw <3 x i8> [[X:%.*]], <i8 124, i8 124, i8 124>
 ; CHECK-NEXT:    [[M:%.*]] = call <3 x i8> @llvm.smin.v3i8(<3 x i8> [[A]], <3 x i8> <i8 -3, i8 -3, i8 -3>)
 ; CHECK-NEXT:    ret <3 x i8> [[M]]
 ;
-  %a = add nsw <3 x i8> %x, <i8 124, i8 124, i8 124>
+  %a = add nsw nuw <3 x i8> %x, <i8 124, i8 124, i8 124>
   %m = call <3 x i8> @llvm.smin.v3i8(<3 x i8> %a, <3 x i8> <i8 -3, i8 -3, i8 -3>)
   ret <3 x i8> %m
 }
@@ -1977,12 +1977,12 @@ define i8 @smin_offset_uses(i8 %x) {
 
 define <3 x i8> @umax_offset(<3 x i8> %x) {
 ; CHECK-LABEL: @umax_offset(
-; CHECK-NEXT:    [[A:%.*]] = add nuw <3 x i8> [[X:%.*]], <i8 3, i8 3, i8 3>
-; CHECK-NEXT:    [[M:%.*]] = call <3 x i8> @llvm.umax.v3i8(<3 x i8> [[A]], <3 x i8> <i8 4, i8 4, i8 4>)
+; CHECK-NEXT:    [[A:%.*]] = add nuw nsw <3 x i8> [[X:%.*]], <i8 127, i8 127, i8 127>
+; CHECK-NEXT:    [[M:%.*]] = call <3 x i8> @llvm.umax.v3i8(<3 x i8> [[A]], <3 x i8> <i8 -126, i8 -126, i8 -126>)
 ; CHECK-NEXT:    ret <3 x i8> [[M]]
 ;
-  %a = add nuw <3 x i8> %x, <i8 3, i8 3, i8 3>
-  %m = call <3 x i8> @llvm.umax.v3i8(<3 x i8> %a, <3 x i8> <i8 4, i8 4, i8 4>)
+  %a = add nsw nuw <3 x i8> %x, <i8 127, i8 127, i8 127>
+  %m = call <3 x i8> @llvm.umax.v3i8(<3 x i8> %a, <3 x i8> <i8 130, i8 130, i8 130>)
   ret <3 x i8> %m
 }
 
@@ -2082,3 +2082,14 @@ define i8 @umin_offset_uses(i8 %x) {
   %m = call i8 @llvm.umin.i8(i8 %a, i8 252)
   ret i8 %m
 }
+
+define <3 x i8> @umax_vector_splat_undef(<3 x i8> %x) {
+; CHECK-LABEL: @umax_vector_splat_undef(
+; CHECK-NEXT:    [[A:%.*]] = add nuw <3 x i8> [[X:%.*]], <i8 undef, i8 64, i8 64>
+; CHECK-NEXT:    [[R:%.*]] = call <3 x i8> @llvm.umax.v3i8(<3 x i8> [[A]], <3 x i8> <i8 13, i8 -126, i8 -126>)
+; CHECK-NEXT:    ret <3 x i8> [[R]]
+;
+  %a = add nuw <3 x i8> %x, <i8 undef, i8 64, i8 64>
+  %r = call <3 x i8> @llvm.umax.v3i8(<3 x i8> %a, <3 x i8> <i8 13, i8 130, i8 130>)
+  ret <3 x i8> %r
+}


        


More information about the llvm-commits mailing list