diff options
| author | Artur Pilipenko <apilipenko@azulsystems.com> | 2019-09-24 23:21:07 +0000 |
|---|---|---|
| committer | Artur Pilipenko <apilipenko@azulsystems.com> | 2019-09-24 23:21:07 +0000 |
| commit | 5c1447cd438455f3b1b4ea7c8e1dab01d559c105 (patch) | |
| tree | 4b2559a47322c7ab04e681bb378b6ec5b53979f0 /llvm/lib/Analysis | |
| parent | 56eae602da92fc6badc10f1686ec2f6169674b42 (diff) | |
| download | bcm5719-llvm-5c1447cd438455f3b1b4ea7c8e1dab01d559c105.tar.gz bcm5719-llvm-5c1447cd438455f3b1b4ea7c8e1dab01d559c105.zip | |
[SCEV] Disable canonical expansion for non-affine addrecs.
Reviewed By: apilipenko
Differential Revision: https://reviews.llvm.org/D65276
Patch by Evgeniy Brevnov (ybrevnov@azul.com)
llvm-svn: 372789
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index e8a95d35482..251717f64e0 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp @@ -1486,7 +1486,18 @@ Value *SCEVExpander::expandAddRecExprLiterally(const SCEVAddRecExpr *S) { } Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) { - if (!CanonicalMode) return expandAddRecExprLiterally(S); + // In canonical mode we compute the addrec as an expression of a canonical IV + // using evaluateAtIteration and expand the resulting SCEV expression. This + // way we avoid introducing new IVs to carry on the comutation of the addrec + // throughout the loop. + // + // For nested addrecs evaluateAtIteration might need a canonical IV of a + // type wider than the addrec itself. Emitting a canonical IV of the + // proper type might produce non-legal types, for example expanding an i64 + // {0,+,2,+,1} addrec would need an i65 canonical IV. To avoid this just fall + // back to non-canonical mode for nested addrecs. + if (!CanonicalMode || (S->getNumOperands() > 2)) + return expandAddRecExprLiterally(S); Type *Ty = SE.getEffectiveSCEVType(S->getType()); const Loop *L = S->getLoop(); |

