From 6f5229d7da594d63ee954346e06d3e508f9ee07a Mon Sep 17 00:00:00 2001 From: Max Kazantsev Date: Wed, 1 Nov 2017 13:21:56 +0000 Subject: Revert rL311205 "[IRCE] Fix buggy behavior in Clamp" This patch reverts rL311205 that was initially a wrong fix. The real problem was in intersection of signed and unsigned ranges (see rL316552), and the patch being reverted masked the problem instead of fixing it. By now, the test against which rL311205 was made works OK even without this code. This revert patch also contains a test case that demonstrates incorrect behavior caused by rL311205: it is caused by incorrect choise of signed max instead of unsigned. llvm-svn: 317088 --- llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp') diff --git a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp index d7361c03f02..01f7a969ba9 100644 --- a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp +++ b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp @@ -1132,8 +1132,7 @@ LoopConstrainer::calculateSubRanges(bool IsSignedPredicate) const { } auto Clamp = [this, Smallest, Greatest, IsSignedPredicate](const SCEV *S) { - bool MaybeNegativeValues = IsSignedPredicate || !SE.isKnownNonNegative(S); - return MaybeNegativeValues + return IsSignedPredicate ? SE.getSMaxExpr(Smallest, SE.getSMinExpr(Greatest, S)) : SE.getUMaxExpr(Smallest, SE.getUMinExpr(Greatest, S)); }; -- cgit v1.2.3