[llvm] d6ee8f3 - [InstSimplify] Add additional test for select icmp of umin (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 06:09:42 PDT 2023


Author: Nikita Popov
Date: 2023-04-24T15:09:33+02:00
New Revision: d6ee8f3181ff9a1d60571850f16aad752c98ec40

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

LOG: [InstSimplify] Add additional test for select icmp of umin (NFC)

This is a representative test for the simplifyWithOpReplaced()
fold on intrinsics.

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/select-maxmin.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/select-maxmin.ll b/llvm/test/Transforms/InstSimplify/select-maxmin.ll
index 1fc9a8efa509..34a3203908e6 100644
--- a/llvm/test/Transforms/InstSimplify/select-maxmin.ll
+++ b/llvm/test/Transforms/InstSimplify/select-maxmin.ll
@@ -2133,3 +2133,16 @@ define <4 x i8> @ult_yx_umax_select_y_shuf_mask_fval(<4 x i8> %x, <4 x i8> %y) {
   %r = select <4 x i1> %i, <4 x i8> %x, <4 x i8> %s
   ret <4 x i8> %r
 }
+
+define i8 @select_umin_with_icmp_zero(i8 %x, i8 %y) {
+; CHECK-LABEL: @select_umin_with_icmp_zero(
+; CHECK-NEXT:    [[MIN:%.*]] = call i8 @llvm.umin.i8(i8 [[X:%.*]], i8 [[Y:%.*]])
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[X]], 0
+; CHECK-NEXT:    [[SEL:%.*]] = select i1 [[CMP]], i8 [[MIN]], i8 0
+; CHECK-NEXT:    ret i8 [[SEL]]
+;
+  %min = call i8 @llvm.umin.i8(i8 %x, i8 %y)
+  %cmp = icmp eq i8 %x, 0
+  %sel = select i1 %cmp, i8 %min, i8 0
+  ret i8 %sel
+}


        


More information about the llvm-commits mailing list