summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2017-11-17 06:49:26 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2017-11-17 06:49:26 +0000
commit1ac6e8ae61cfaa5729284e4707b51d30f4a390e1 (patch)
treefc44aac683756f8751cef0e74f62ae382e93cecd /llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
parentb5b0c022497a1fc68248d0a494f494b99456e7ec (diff)
downloadbcm5719-llvm-1ac6e8ae61cfaa5729284e4707b51d30f4a390e1.tar.gz
bcm5719-llvm-1ac6e8ae61cfaa5729284e4707b51d30f4a390e1.zip
[IRCE] Remove folding of two range checks into RANGE_CHECK_BOTH
The logic of replacing of a couple `RANGE_CHECK_LOWER + RANGE_CHECK_UPPER` into `RANGE_CHECK_BOTH` in fact duplicates the logic of range intersection which happens when we calculate safe iteration space. Effectively, the result of intersection of these ranges doesn't differ from the range of merged range check. We chose to remove duplicating logic in favor of code simplicity. Differential Revision: https://reviews.llvm.org/D39589 llvm-svn: 318508
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp31
1 files changed, 3 insertions, 28 deletions
diff --git a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
index c83dc5d7a9d..9f514e609c4 100644
--- a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
@@ -367,37 +367,12 @@ void InductiveRangeCheck::extractRangeChecksFromCond(
if (!Visited.insert(Condition).second)
return;
+ // TODO: Do the same for OR, XOR, NOT etc?
if (match(Condition, m_And(m_Value(), m_Value()))) {
- SmallVector<InductiveRangeCheck, 8> SubChecks;
extractRangeChecksFromCond(L, SE, cast<User>(Condition)->getOperandUse(0),
- SubChecks, Visited);
+ Checks, Visited);
extractRangeChecksFromCond(L, SE, cast<User>(Condition)->getOperandUse(1),
- SubChecks, Visited);
-
- if (SubChecks.size() == 2) {
- // Handle a special case where we know how to merge two checks separately
- // checking the upper and lower bounds into a full range check.
- const auto &RChkA = SubChecks[0];
- const auto &RChkB = SubChecks[1];
- if ((RChkA.End == RChkB.End || !RChkA.End || !RChkB.End) &&
- RChkA.Begin == RChkB.Begin && RChkA.Step == RChkB.Step &&
- RChkA.IsSigned == RChkB.IsSigned) {
- // If RChkA.Kind == RChkB.Kind then we just found two identical checks.
- // But if one of them is a RANGE_CHECK_LOWER and the other is a
- // RANGE_CHECK_UPPER (only possibility if they're different) then
- // together they form a RANGE_CHECK_BOTH.
- SubChecks[0].Kind =
- (InductiveRangeCheck::RangeCheckKind)(RChkA.Kind | RChkB.Kind);
- SubChecks[0].End = RChkA.End ? RChkA.End : RChkB.End;
- SubChecks[0].CheckUse = &ConditionUse;
- SubChecks[0].IsSigned = RChkA.IsSigned;
-
- // We updated one of the checks in place, now erase the other.
- SubChecks.pop_back();
- }
- }
-
- Checks.insert(Checks.end(), SubChecks.begin(), SubChecks.end());
+ Checks, Visited);
return;
}
OpenPOWER on IntegriCloud