[llvm] cc8f981 - [InstCombine] add tests to show miscompiled smin/smax; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 9 14:52:32 PST 2022


Author: Sanjay Patel
Date: 2022-03-09T17:50:34-05:00
New Revision: cc8f98198799fe3a5f00e2fc0edcb5d90c124d2f

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

LOG: [InstCombine] add tests to show miscompiled smin/smax; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/select-min-max.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/select-min-max.ll b/llvm/test/Transforms/InstCombine/select-min-max.ll
index b285c7ee54b47..04dc62ec2f920 100644
--- a/llvm/test/Transforms/InstCombine/select-min-max.ll
+++ b/llvm/test/Transforms/InstCombine/select-min-max.ll
@@ -249,3 +249,51 @@ define i8 @umin_umax(i8 %x) {
   %s = select i1 %c, i8 %m, i8 126
   ret i8 %s
 }
+
+define i8 @not_smax(i8 %i41, i8 %i43) {
+; CHECK-LABEL: @not_smax(
+; CHECK-NEXT:    [[I46:%.*]] = sub nsw i8 [[I41:%.*]], [[I43:%.*]]
+; CHECK-NEXT:    [[TMP1:%.*]] = call i8 @llvm.smax.i8(i8 [[I46]], i8 0)
+; CHECK-NEXT:    ret i8 [[TMP1]]
+;
+  %i44 = icmp slt i8 %i41, %i43
+  %i46 = sub nsw i8 %i41, %i43
+  %spec.select = select i1 %i44, i8 0, i8 %i46
+  ret i8 %spec.select
+}
+
+define i8 @not_smax_swap(i8 %i41, i8 %i43) {
+; CHECK-LABEL: @not_smax_swap(
+; CHECK-NEXT:    [[I46:%.*]] = sub nsw i8 [[I41:%.*]], [[I43:%.*]]
+; CHECK-NEXT:    [[TMP1:%.*]] = call i8 @llvm.smax.i8(i8 [[I46]], i8 0)
+; CHECK-NEXT:    ret i8 [[TMP1]]
+;
+  %i44 = icmp sgt i8 %i41, %i43
+  %i46 = sub nsw i8 %i41, %i43
+  %spec.select = select i1 %i44, i8 %i46, i8 0
+  ret i8 %spec.select
+}
+
+define i8 @not_smin(i8 %i41, i8 %i43) {
+; CHECK-LABEL: @not_smin(
+; CHECK-NEXT:    [[I46:%.*]] = sub nsw i8 [[I41:%.*]], [[I43:%.*]]
+; CHECK-NEXT:    [[TMP1:%.*]] = call i8 @llvm.smin.i8(i8 [[I46]], i8 0)
+; CHECK-NEXT:    ret i8 [[TMP1]]
+;
+  %i44 = icmp sgt i8 %i41, %i43
+  %i46 = sub nsw i8 %i41, %i43
+  %spec.select = select i1 %i44, i8 0, i8 %i46
+  ret i8 %spec.select
+}
+
+define i8 @not_smin_swap(i8 %i41, i8 %i43) {
+; CHECK-LABEL: @not_smin_swap(
+; CHECK-NEXT:    [[I46:%.*]] = sub nsw i8 [[I41:%.*]], [[I43:%.*]]
+; CHECK-NEXT:    [[TMP1:%.*]] = call i8 @llvm.smin.i8(i8 [[I46]], i8 0)
+; CHECK-NEXT:    ret i8 [[TMP1]]
+;
+  %i44 = icmp slt i8 %i41, %i43
+  %i46 = sub nsw i8 %i41, %i43
+  %spec.select = select i1 %i44, i8 %i46, i8 0
+  ret i8 %spec.select
+}


        


More information about the llvm-commits mailing list