diff options
| author | David Majnemer <david.majnemer@gmail.com> | 2013-06-04 17:51:58 +0000 |
|---|---|---|
| committer | David Majnemer <david.majnemer@gmail.com> | 2013-06-04 17:51:58 +0000 |
| commit | 29130c5e8d3d49b063859d43b3c00097fbee6ccd (patch) | |
| tree | e35861bac315f3e4992306bdbffcdfe66d16c4bf /llvm/lib/Transforms | |
| parent | 452f1f97bd6df8a94632664e67c5ed905b40897b (diff) | |
| download | bcm5719-llvm-29130c5e8d3d49b063859d43b3c00097fbee6ccd.tar.gz bcm5719-llvm-29130c5e8d3d49b063859d43b3c00097fbee6ccd.zip | |
IndVarSimplify: check if loop invariant expansion can trap
IndVarSimplify is willing to move divide instructions outside of their
loop bodies if they are invariant of the loop. However, it may not be
safe to expand them if we do not know if they can trap.
Instead, check to see if it is not safe to expand the instruction and
skip the expansion.
This fixes PR16041.
Testcase by Rafael Ávila de Espíndola.
llvm-svn: 183239
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index 8e76c78f5ac..df11e92c9ed 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -532,7 +532,7 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter) { // and varies predictably *inside* the loop. Evaluate the value it // contains when the loop exits, if possible. const SCEV *ExitValue = SE->getSCEVAtScope(Inst, L->getParentLoop()); - if (!SE->isLoopInvariant(ExitValue, L)) + if (!SE->isLoopInvariant(ExitValue, L) || !isSafeToExpand(ExitValue)) continue; // Computing the value outside of the loop brings no benefit if : |

