diff options
| author | Dan Gohman <gohman@apple.com> | 2010-06-29 01:41:41 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-06-29 01:41:41 +0000 |
| commit | 90db61d63874d8381b36d093c26d682d9d95d9ad (patch) | |
| tree | a3383c31d5af01210f3def8c9df4295dad47d3a0 /llvm/lib | |
| parent | de736a649406770d5e416055af4cdeb770de25c4 (diff) | |
| download | bcm5719-llvm-90db61d63874d8381b36d093c26d682d9d95d9ad.tar.gz bcm5719-llvm-90db61d63874d8381b36d093c26d682d9d95d9ad.zip | |
Just as its not safe to blindly transfer the nsw bit from an add
instruction to an add scev, it's not safe to blindly transfer the
inbounds flag from a gep instruction to an nsw on the scev for the
gep.
llvm-svn: 107117
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 55636902495..a416764cda2 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -2763,7 +2763,11 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) { /// const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) { - bool InBounds = GEP->isInBounds(); + // Don't transfer the inbounds flag from the GEP instruction to the + // Add expression, because the Instruction may be guarded by control + // flow and the no-overflow bits may not be valid for the expression in + // any context. + const Type *IntPtrTy = getEffectiveSCEVType(GEP->getType()); Value *Base = GEP->getOperand(0); // Don't attempt to analyze GEPs over unsized objects. @@ -2781,7 +2785,7 @@ const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) { unsigned FieldNo = cast<ConstantInt>(Index)->getZExtValue(); TotalOffset = getAddExpr(TotalOffset, getOffsetOfExpr(STy, FieldNo), - /*HasNUW=*/false, /*HasNSW=*/InBounds); + /*HasNUW=*/false, /*HasNSW=*/false); } else { // For an array, add the element offset, explicitly scaled. const SCEV *LocalOffset = getSCEV(Index); @@ -2789,13 +2793,13 @@ const SCEV *ScalarEvolution::createNodeForGEP(GEPOperator *GEP) { LocalOffset = getTruncateOrSignExtend(LocalOffset, IntPtrTy); // Lower "inbounds" GEPs to NSW arithmetic. LocalOffset = getMulExpr(LocalOffset, getSizeOfExpr(*GTI), - /*HasNUW=*/false, /*HasNSW=*/InBounds); + /*HasNUW=*/false, /*HasNSW=*/false); TotalOffset = getAddExpr(TotalOffset, LocalOffset, - /*HasNUW=*/false, /*HasNSW=*/InBounds); + /*HasNUW=*/false, /*HasNSW=*/false); } } return getAddExpr(getSCEV(Base), TotalOffset, - /*HasNUW=*/false, /*HasNSW=*/InBounds); + /*HasNUW=*/false, /*HasNSW=*/false); } /// GetMinTrailingZeros - Determine the minimum number of zero bits that S is |

