diff options
| author | Dan Gohman <gohman@apple.com> | 2009-05-26 17:41:16 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2009-05-26 17:41:16 +0000 |
| commit | 9fe212806bfb75d51b9b23d2aa9b5d96a816eef7 (patch) | |
| tree | 3a65f58db84e42caa13351b990b3ba1c7d7cac0c /llvm/lib/Analysis/ScalarEvolutionExpander.cpp | |
| parent | 33794edae76715ba5a9fda3107b4376d6f0626f0 (diff) | |
| download | bcm5719-llvm-9fe212806bfb75d51b9b23d2aa9b5d96a816eef7.tar.gz bcm5719-llvm-9fe212806bfb75d51b9b23d2aa9b5d96a816eef7.zip | |
In cases where a pointer value is an operand of a multiplication or
division operation, don't attempt to use the operation's value as
the base of a getelementptr. This fixes PR4271.
llvm-svn: 72422
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolutionExpander.cpp')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolutionExpander.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp index 191fcc02c4b..6992b998802 100644 --- a/llvm/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/llvm/lib/Analysis/ScalarEvolutionExpander.cpp @@ -448,9 +448,14 @@ Value *SCEVExpander::visitAddRecExpr(const SCEVAddRecExpr *S) { ExposePointerBase(Base, RestArray[0], SE); // If we found a pointer, expand the AddRec with a GEP. if (const PointerType *PTy = dyn_cast<PointerType>(Base->getType())) { - Value *StartV = expand(Base); - assert(StartV->getType() == PTy && "Pointer type mismatch for GEP!"); - return expandAddToGEP(RestArray, RestArray+1, PTy, Ty, StartV); + // Make sure the Base isn't something exotic, such as a multiplied + // or divided pointer value. In those cases, the result type isn't + // actually a pointer type. + if (!isa<SCEVMulExpr>(Base) && !isa<SCEVUDivExpr>(Base)) { + Value *StartV = expand(Base); + assert(StartV->getType() == PTy && "Pointer type mismatch for GEP!"); + return expandAddToGEP(RestArray, RestArray+1, PTy, Ty, StartV); + } } } |

