diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2016-02-12 19:05:27 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2016-02-12 19:05:27 +0000 |
commit | 4acff966462d17aa2d22100e8ed8742baefca4b8 (patch) | |
tree | 7fcd85b2ed5f9b49b25e0ffa5051ccc1217be552 /llvm/lib | |
parent | 2b9100dfbd4219727c6904e76403efda0d2d5e63 (diff) | |
download | bcm5719-llvm-4acff966462d17aa2d22100e8ed8742baefca4b8.tar.gz bcm5719-llvm-4acff966462d17aa2d22100e8ed8742baefca4b8.zip |
[LIR] Partially revert r252926(NFC), which introduced a very subtle change.
In short, before r252926 we were comparing an unsigned (StoreSize) against an a
APInt (Stride), which is fine and well. After we were zero extending the Stride
and then converting to an unsigned, which is not the same thing. Obviously,
Stides can also be negative. This commit just restores the original behavior.
AFAICT, it's not possible to write a test case to expose the issue because
the code already has checks to make sure the StoreSize can't overflow an
unsigned (which prevents the Stride from overflowing an unsigned as well).
llvm-svn: 260706
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index edcc0156e88..a19c223f7ec 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -262,9 +262,9 @@ static unsigned getStoreSizeInBytes(StoreInst *SI, const DataLayout *DL) { return (unsigned)SizeInBits >> 3; } -static unsigned getStoreStride(const SCEVAddRecExpr *StoreEv) { +static APInt getStoreStride(const SCEVAddRecExpr *StoreEv) { const SCEVConstant *ConstStride = cast<SCEVConstant>(StoreEv->getOperand(1)); - return ConstStride->getAPInt().getZExtValue(); + return ConstStride->getAPInt(); } /// getMemSetPatternValue - If a strided store of the specified value is safe to @@ -365,7 +365,7 @@ bool LoopIdiomRecognize::isLegalStore(StoreInst *SI, bool &ForMemset, if (HasMemcpy) { // Check to see if the stride matches the size of the store. If so, then we // know that every byte is touched in the loop. - unsigned Stride = getStoreStride(StoreEv); + APInt Stride = getStoreStride(StoreEv); unsigned StoreSize = getStoreSizeInBytes(SI, DL); if (StoreSize != Stride && StoreSize != -Stride) return false; @@ -493,11 +493,11 @@ bool LoopIdiomRecognize::processLoopStores(SmallVectorImpl<StoreInst *> &SL, Value *FirstStorePtr = SL[i]->getPointerOperand(); const SCEVAddRecExpr *FirstStoreEv = cast<SCEVAddRecExpr>(SE->getSCEV(FirstStorePtr)); - unsigned FirstStride = getStoreStride(FirstStoreEv); + APInt FirstStride = getStoreStride(FirstStoreEv); unsigned FirstStoreSize = getStoreSizeInBytes(SL[i], DL); // See if we can optimize just this store in isolation. - if (FirstStride == FirstStoreSize || FirstStride == -FirstStoreSize) { + if (FirstStride == FirstStoreSize || -FirstStride == FirstStoreSize) { Heads.insert(SL[i]); continue; } @@ -529,7 +529,7 @@ bool LoopIdiomRecognize::processLoopStores(SmallVectorImpl<StoreInst *> &SL, Value *SecondStorePtr = SL[k]->getPointerOperand(); const SCEVAddRecExpr *SecondStoreEv = cast<SCEVAddRecExpr>(SE->getSCEV(SecondStorePtr)); - unsigned SecondStride = getStoreStride(SecondStoreEv); + APInt SecondStride = getStoreStride(SecondStoreEv); if (FirstStride != SecondStride) continue; @@ -595,7 +595,7 @@ bool LoopIdiomRecognize::processLoopStores(SmallVectorImpl<StoreInst *> &SL, Value *StoredVal = HeadStore->getValueOperand(); Value *StorePtr = HeadStore->getPointerOperand(); const SCEVAddRecExpr *StoreEv = cast<SCEVAddRecExpr>(SE->getSCEV(StorePtr)); - unsigned Stride = getStoreStride(StoreEv); + APInt Stride = getStoreStride(StoreEv); // Check to see if the stride matches the size of the stores. If so, then // we know that every byte is touched in the loop. @@ -817,7 +817,7 @@ bool LoopIdiomRecognize::processLoopStoreOfLoopLoad(StoreInst *SI, Value *StorePtr = SI->getPointerOperand(); const SCEVAddRecExpr *StoreEv = cast<SCEVAddRecExpr>(SE->getSCEV(StorePtr)); - unsigned Stride = getStoreStride(StoreEv); + APInt Stride = getStoreStride(StoreEv); unsigned StoreSize = getStoreSizeInBytes(SI, DL); bool NegStride = StoreSize == -Stride; |