[PATCH] D109957: [SCEV] Support negative values in signed/unsigned predicate reasoning
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 19 21:28:15 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdef15c5fb6a1: [SCEV] Support negative values in signed/unsigned predicate reasoning (authored by mkazantsev).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109957/new/
https://reviews.llvm.org/D109957
Files:
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Transforms/IndVarSimplify/negative_ranges.ll
Index: llvm/test/Transforms/IndVarSimplify/negative_ranges.ll
===================================================================
--- llvm/test/Transforms/IndVarSimplify/negative_ranges.ll
+++ llvm/test/Transforms/IndVarSimplify/negative_ranges.ll
@@ -53,7 +53,6 @@
ret i32 0
}
-; FIXME: 2nd check is implied by the 1st one as both values are negative.
define i32 @test_02(i32* %p, i32* %s) {
; CHECK-LABEL: @test_02(
; CHECK-NEXT: entry:
@@ -65,8 +64,7 @@
; CHECK-NEXT: [[C1:%.*]] = icmp ult i32 [[IV]], [[END]]
; CHECK-NEXT: br i1 [[C1]], label [[GUARDED:%.*]], label [[SIDE_EXIT:%.*]]
; CHECK: guarded:
-; CHECK-NEXT: [[C2:%.*]] = icmp slt i32 [[IV]], [[END]]
-; CHECK-NEXT: br i1 [[C2]], label [[BACKEDGE]], label [[SIDE_EXIT]]
+; CHECK-NEXT: br i1 true, label [[BACKEDGE]], label [[SIDE_EXIT]]
; CHECK: backedge:
; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i32 [[IV]], 1
; CHECK-NEXT: [[LOOP_COND:%.*]] = call i1 @cond()
Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -10703,10 +10703,11 @@
}
// Unsigned comparison is the same as signed comparison when both the operands
- // are non-negative.
+ // are non-negative or negative.
if (CmpInst::isUnsigned(FoundPred) &&
CmpInst::getSignedPredicate(FoundPred) == Pred &&
- isKnownNonNegative(FoundLHS) && isKnownNonNegative(FoundRHS))
+ ((isKnownNonNegative(FoundLHS) && isKnownNonNegative(FoundRHS)) ||
+ (isKnownNegative(FoundLHS) && isKnownNegative(FoundRHS))))
return isImpliedCondOperands(Pred, LHS, RHS, FoundLHS, FoundRHS, Context);
// Check if we can make progress by sharpening ranges.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109957.373488.patch
Type: text/x-patch
Size: 1791 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210920/17bacffc/attachment.bin>
More information about the llvm-commits
mailing list