[PATCH] D47951: [SCEV] Look through zero-extends in howFarToZero
Krzysztof Parzyszek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 8 09:56:27 PDT 2018
kparzysz created this revision.
kparzysz added reviewers: sanjoy, eli.friedman.
An expression like `(zext i2 {(trunc i32 (1 + %B) to i2),+,1}<%while.body> to i32)` will become zero exactly when the nested value becomes zero in its type. Instead of converting this kind of a zero-extended value into an addrec with predicates, simply remove the zext.
This is the replacement of https://reviews.llvm.org/D47899 (the motivation is explained there).
Repository:
rL LLVM
https://reviews.llvm.org/D47951
Files:
lib/Analysis/ScalarEvolution.cpp
Index: lib/Analysis/ScalarEvolution.cpp
===================================================================
--- lib/Analysis/ScalarEvolution.cpp
+++ lib/Analysis/ScalarEvolution.cpp
@@ -8265,7 +8265,6 @@
ScalarEvolution::ExitLimit
ScalarEvolution::howFarToZero(const SCEV *V, const Loop *L, bool ControlsExit,
bool AllowPredicates) {
-
// This is only used for loops with a "x != y" exit test. The exit condition
// is now expressed as a single expression, V = x-y. So the exit test is
// effectively V != 0. We know and take advantage of the fact that this
@@ -8280,6 +8279,12 @@
}
const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(V);
+ if (!AddRec) {
+ if (const SCEVZeroExtendExpr *Z = dyn_cast<SCEVZeroExtendExpr>(V))
+ if (const SCEVAddRecExpr *A = dyn_cast<SCEVAddRecExpr>(Z->getOperand()))
+ AddRec = A;
+ }
+
if (!AddRec && AllowPredicates)
// Try to make this an AddRec using runtime tests, in the first X
// iterations of this loop, where X is the SCEV expression found by the
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47951.150532.patch
Type: text/x-patch
Size: 1075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180608/029cef09/attachment.bin>
More information about the llvm-commits
mailing list