diff options
| author | Vitaly Buka <vitalybuka@google.com> | 2019-07-10 22:53:52 +0000 |
|---|---|---|
| committer | Vitaly Buka <vitalybuka@google.com> | 2019-07-10 22:53:52 +0000 |
| commit | d03bd1db59496079dfecf9e3d2bd79b6b6c7659b (patch) | |
| tree | b1cf7f5ccfe694ab353e9179faace626a51f4460 /llvm/lib/Transforms | |
| parent | e72676657f3e2f3e29125efc8c12bcb477cda445 (diff) | |
| download | bcm5719-llvm-d03bd1db59496079dfecf9e3d2bd79b6b6c7659b.tar.gz bcm5719-llvm-d03bd1db59496079dfecf9e3d2bd79b6b6c7659b.zip | |
NFC: Pass DataLayout into isBytewiseValue
Summary:
We will need to handle IntToPtr which I will submit in a separate patch as it's
not going to be NFC.
Reviewers: eugenis, pcc
Reviewed By: eugenis
Subscribers: hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D63940
llvm-svn: 365709
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp | 7 |
2 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index 811cbf3552a..e561494f19c 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -450,7 +450,7 @@ LoopIdiomRecognize::isLegalStore(StoreInst *SI) { // turned into a memset of i8 -1, assuming that all the consecutive bytes // are stored. A store of i32 0x01020304 can never be turned into a memset, // but it can be turned into memset_pattern if the target supports it. - Value *SplatValue = isBytewiseValue(StoredVal); + Value *SplatValue = isBytewiseValue(StoredVal, *DL); Constant *PatternValue = nullptr; // Note: memset and memset_pattern on unordered-atomic is yet not supported @@ -627,7 +627,7 @@ bool LoopIdiomRecognize::processLoopStores(SmallVectorImpl<StoreInst *> &SL, Constant *FirstPatternValue = nullptr; if (For == ForMemset::Yes) - FirstSplatValue = isBytewiseValue(FirstStoredVal); + FirstSplatValue = isBytewiseValue(FirstStoredVal, *DL); else FirstPatternValue = getMemSetPatternValue(FirstStoredVal, DL); @@ -660,7 +660,7 @@ bool LoopIdiomRecognize::processLoopStores(SmallVectorImpl<StoreInst *> &SL, Constant *SecondPatternValue = nullptr; if (For == ForMemset::Yes) - SecondSplatValue = isBytewiseValue(SecondStoredVal); + SecondSplatValue = isBytewiseValue(SecondStoredVal, *DL); else SecondPatternValue = getMemSetPatternValue(SecondStoredVal, DL); @@ -880,7 +880,7 @@ bool LoopIdiomRecognize::processLoopStridedStore( Value *StoredVal, Instruction *TheStore, SmallPtrSetImpl<Instruction *> &Stores, const SCEVAddRecExpr *Ev, const SCEV *BECount, bool NegStride, bool IsLoopMemset) { - Value *SplatValue = isBytewiseValue(StoredVal); + Value *SplatValue = isBytewiseValue(StoredVal, *DL); Constant *PatternValue = nullptr; if (!SplatValue) diff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp index dfedd7c6fd3..5a055139be4 100644 --- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp +++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp @@ -412,7 +412,7 @@ Instruction *MemCpyOptPass::tryMergingIntoMemset(Instruction *StartInst, if (!NextStore->isSimple()) break; // Check to see if this stored value is of the same byte-splattable value. - Value *StoredByte = isBytewiseValue(NextStore->getOperand(0)); + Value *StoredByte = isBytewiseValue(NextStore->getOperand(0), DL); if (isa<UndefValue>(ByteVal) && StoredByte) ByteVal = StoredByte; if (ByteVal != StoredByte) @@ -749,7 +749,7 @@ bool MemCpyOptPass::processStore(StoreInst *SI, BasicBlock::iterator &BBI) { // byte at a time like "0" or "-1" or any width, as well as things like // 0xA0A0A0A0 and 0.0. auto *V = SI->getOperand(0); - if (Value *ByteVal = isBytewiseValue(V)) { + if (Value *ByteVal = isBytewiseValue(V, DL)) { if (Instruction *I = tryMergingIntoMemset(SI, SI->getPointerOperand(), ByteVal)) { BBI = I->getIterator(); // Don't invalidate iterator. @@ -1229,7 +1229,8 @@ bool MemCpyOptPass::processMemCpy(MemCpyInst *M) { // If copying from a constant, try to turn the memcpy into a memset. if (GlobalVariable *GV = dyn_cast<GlobalVariable>(M->getSource())) if (GV->isConstant() && GV->hasDefinitiveInitializer()) - if (Value *ByteVal = isBytewiseValue(GV->getInitializer())) { + if (Value *ByteVal = isBytewiseValue(GV->getInitializer(), + M->getModule()->getDataLayout())) { IRBuilder<> Builder(M); Builder.CreateMemSet(M->getRawDest(), ByteVal, M->getLength(), M->getDestAlignment(), false); |

