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 | f876ad0a70c5c3bb402de2766237410f041700e6 (patch) | |
tree | a07fdf006edd46999d39b4ad158d42b40de5decd /lib/Analysis/ScalarEvolutionExpander.cpp | |
parent | 74807f2520715056be399a2bc59dfc8b6f8f3eb2 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72422 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolutionExpander.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 191fcc02c4..6992b99880 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/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); + } } } |