[llvm] 4b1525b - [InstCombine] Add test showing failure to fold (icmp sgt smin(PosA, B) 0) -> (icmp sgt B 0) with smin intrinsic
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 10 05:21:24 PST 2022
Author: Simon Pilgrim
Date: 2022-02-10T13:21:06Z
New Revision: 4b1525b964406261e8ecf6786c3042bea9d719aa
URL: https://github.com/llvm/llvm-project/commit/4b1525b964406261e8ecf6786c3042bea9d719aa
DIFF: https://github.com/llvm/llvm-project/commit/4b1525b964406261e8ecf6786c3042bea9d719aa.diff
LOG: [InstCombine] Add test showing failure to fold (icmp sgt smin(PosA, B) 0) -> (icmp sgt B 0) with smin intrinsic
Noticed while reviewing regressions from D98152
Added:
Modified:
llvm/test/Transforms/InstCombine/min-positive.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/min-positive.ll b/llvm/test/Transforms/InstCombine/min-positive.ll
index 8593d8ec6c9a5..83628f3ec0c39 100644
--- a/llvm/test/Transforms/InstCombine/min-positive.ll
+++ b/llvm/test/Transforms/InstCombine/min-positive.ll
@@ -15,6 +15,21 @@ define i1 @smin(i32 %other) {
ret i1 %test
}
+; FIXME: Add intrinsic handling
+define i1 @smin_int(i32 %other) {
+; CHECK-LABEL: @smin_int(
+; CHECK-NEXT: [[POSITIVE:%.*]] = load i32, i32* @g, align 4, !range [[RNG0:![0-9]+]]
+; CHECK-NEXT: [[SMIN:%.*]] = call i32 @llvm.smin.i32(i32 [[POSITIVE]], i32 [[OTHER:%.*]])
+; CHECK-NEXT: [[TEST:%.*]] = icmp sgt i32 [[SMIN]], 0
+; CHECK-NEXT: ret i1 [[TEST]]
+;
+ %positive = load i32, i32* @g, !range !{i32 1, i32 2048}
+ %smin = call i32 @llvm.smin.i32(i32 %positive, i32 %other)
+ %test = icmp sgt i32 %smin, 0
+ ret i1 %test
+}
+declare i32 @llvm.smin.i32(i32, i32)
+
; Range metadata doesn't work for vectors, so find another way to trigger isKnownPositive().
define <2 x i1> @smin_vec(<2 x i32> %x, <2 x i32> %other) {
@@ -71,7 +86,7 @@ define <2 x i1> @smin_commute_vec_undef_elts(<2 x i32> %x, <2 x i32> %other) {
define i1 @maybe_not_positive(i32 %other) {
; CHECK-LABEL: @maybe_not_positive(
-; CHECK-NEXT: [[POSITIVE:%.*]] = load i32, i32* @g, align 4, !range !0
+; CHECK-NEXT: [[POSITIVE:%.*]] = load i32, i32* @g, align 4, !range [[RNG1:![0-9]+]]
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[POSITIVE]], [[OTHER:%.*]]
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i32 [[POSITIVE]], i32 [[OTHER]]
; CHECK-NEXT: [[TEST:%.*]] = icmp sgt i32 [[SEL]], 0
More information about the llvm-commits
mailing list