diff options
author | Sanjay Patel <spatel@rotateright.com> | 2022-03-09 17:18:35 -0500 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2022-03-09 17:50:34 -0500 |
commit | cc8f98198799fe3a5f00e2fc0edcb5d90c124d2f (patch) | |
tree | d444004b859627d2c31933d12b0dcbb54e78eaa0 | |
parent | 0be6fd44f363d5756a3c796e1875567a037a0920 (diff) |
[InstCombine] add tests to show miscompiled smin/smax; NFC
-rw-r--r-- | llvm/test/Transforms/InstCombine/select-min-max.ll | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/select-min-max.ll b/llvm/test/Transforms/InstCombine/select-min-max.ll index b285c7ee54b4..04dc62ec2f92 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 +} |