[PATCH] D34566: [loop idiom Recognition] support memcpy for multiple consecutive loads and stores
Haicheng Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 15:05:13 PDT 2017
haicheng added inline comments.
================
Comment at: lib/Transforms/Scalar/LoopIdiomRecognize.cpp:830
+/// Otherwise, If there are one or multiple stored values, which are strided
+/// loads in the same loop with the same stride ,(with the stores being
+/// consecutive and having a common base, similarly the loads also being
----------------
a space between stride and comma.
================
Comment at: lib/Transforms/Scalar/LoopIdiomRecognize.cpp:847-857
Value *SplatValue = isBytewiseValue(StoredVal);
Constant *PatternValue = nullptr;
+ if (MemIdiom == LegalStoreKind::Memset ||
+ MemIdiom == LegalStoreKind::MemsetPattern) {
- if (!SplatValue)
- PatternValue = getMemSetPatternValue(StoredVal, DL);
+ if (!SplatValue)
+ PatternValue = getMemSetPatternValue(StoredVal, DL);
----------------
This part can be written as
```
if (Memset)
SplatValue =
else if (memsetpattern)
Patternvalue =
```
================
Comment at: lib/Transforms/Scalar/LoopIdiomRecognize.cpp:966
+ MemIdiom == LegalStoreKind::MemsetPattern) {
+ if (SplatValue) {
+ NewCall =
----------------
This can be changed to
if (memset)
================
Comment at: lib/Transforms/Scalar/LoopIdiomRecognize.cpp:969
+ Builder.CreateMemSet(BasePtr, SplatValue, NumBytes, StoreAlignment);
+ } else {
+ // Everything is emitted in default address space
----------------
this can be changed to
else if (memset_pattern)
================
Comment at: lib/Transforms/Scalar/LoopIdiomRecognize.cpp:1022-1029
+ NewCall->setDebugLoc(TheStore->getDebugLoc());
- // Propagate alignment info onto the pointer args. Note that unordered
- // atomic loads/stores are *required* by the spec to have an alignment
- // but non-atomic loads/stores may not.
- NewCall->addParamAttr(0, Attribute::getWithAlignment(NewCall->getContext(),
- SI->getAlignment()));
- NewCall->addParamAttr(1, Attribute::getWithAlignment(NewCall->getContext(),
- LI->getAlignment()));
+ DEBUG(dbgs() << " Formed memcpy: " << *NewCall << "\n"
+ << " from load ptr=" << *LoadEv << " at: " << *StoreLoadInst
+ << "\n"
+ << " from store ptr=" << *Ev << " at: " << *TheStore
+ << "\n");
----------------
I think after creating newCall, setDebugLoc and debug dumping can be refactored too.
https://reviews.llvm.org/D34566
More information about the llvm-commits
mailing list