diff options
author | Andrew Trick <atrick@apple.com> | 2011-06-30 19:02:17 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2011-06-30 19:02:17 +0000 |
commit | 6e0ce24e0ca8b0dc05872b9b4cec3a18972bee40 (patch) | |
tree | b947070dc15f3de66e7bcee1f32c9cde490f55dd /lib/Transforms/Scalar/IndVarSimplify.cpp | |
parent | 16f9924000a8d513353cd5c69d1d6307016fe280 (diff) |
indvars -disable-iv-rewrite: handle cloning binary operators that cannot overflow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/IndVarSimplify.cpp')
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 00f8831eb2..77642e5c11 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -659,9 +659,11 @@ Instruction *WidenIV::CloneIVUser(Instruction *NarrowUse, LHS, RHS, NarrowBO->getName()); Builder.Insert(WideBO); - if (NarrowBO->hasNoUnsignedWrap()) WideBO->setHasNoUnsignedWrap(); - if (NarrowBO->hasNoSignedWrap()) WideBO->setHasNoSignedWrap(); - + if (const OverflowingBinaryOperator *OBO = + dyn_cast<OverflowingBinaryOperator>(NarrowBO)) { + if (OBO->hasNoUnsignedWrap()) WideBO->setHasNoUnsignedWrap(); + if (OBO->hasNoSignedWrap()) WideBO->setHasNoSignedWrap(); + } return WideBO; } llvm_unreachable(0); @@ -1121,6 +1123,8 @@ void IndVarSimplify::SimplifyIVUsersNoRewrite(Loop *L, SCEVExpander &Rewriter) { while (!SimpleIVUsers.empty()) { Instruction *UseInst, *Operand; tie(UseInst, Operand) = SimpleIVUsers.pop_back_val(); + // Bypass back edges to avoid extra work. + if (UseInst == CurrIV) continue; if (EliminateIVUser(UseInst, Operand)) { pushIVUsers(Operand, Simplified, SimpleIVUsers); |