diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-08-19 21:43:16 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2013-08-19 21:43:16 +0000 |
commit | c4d070ad07c606f77af15604dbbe817edd11ca9c (patch) | |
tree | b74faa0cafbb3849088bb1117dab579637810b00 /lib/Analysis | |
parent | 05bae3bfe47b63976cfa63b4756d3e768dd9eebc (diff) | |
download | external_llvm-c4d070ad07c606f77af15604dbbe817edd11ca9c.zip external_llvm-c4d070ad07c606f77af15604dbbe817edd11ca9c.tar.gz external_llvm-c4d070ad07c606f77af15604dbbe817edd11ca9c.tar.bz2 |
Fix assert with GEP ptr vector indexing structs
Also fix it calculating the wrong value. The struct index
is not a ConstantInt, so it was being interpreted as an array
index.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188713 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/ValueTracking.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 6e38061..c815375 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -629,9 +629,19 @@ void llvm::ComputeMaskedBits(Value *V, APInt &KnownZero, APInt &KnownOne, Value *Index = I->getOperand(i); if (StructType *STy = dyn_cast<StructType>(*GTI)) { // Handle struct member offset arithmetic. - if (!TD) return; - const StructLayout *SL = TD->getStructLayout(STy); + if (!TD) + return; + + // Handle case when index is vector zeroinitializer + Constant *CIndex = cast<Constant>(Index); + if (CIndex->isZeroValue()) + continue; + + if (CIndex->getType()->isVectorTy()) + Index = CIndex->getSplatValue(); + unsigned Idx = cast<ConstantInt>(Index)->getZExtValue(); + const StructLayout *SL = TD->getStructLayout(STy); uint64_t Offset = SL->getElementOffset(Idx); TrailZ = std::min<unsigned>(TrailZ, countTrailingZeros(Offset)); |