[PATCH] D108289: [NFC][LoopIdiom] Let processLoopStoreOfLoopLoad take StoreSize as SCEV instead of unsigned

Yueh-Ting Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 19 01:16:23 PDT 2021


eopXD added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp:891-892
 
-  return processLoopStoreOfLoopLoad(Dest, Source, (unsigned)SizeInBytes,
+  const SCEV *MemCpySizeSCEV = SE->getSCEV(MCI->getLength());
+  return processLoopStoreOfLoopLoad(Dest, Source, MemCpySizeSCEV,
                                     MCI->getDestAlign(), MCI->getSourceAlign(),
----------------
bmahjour wrote:
> why not:
> ```
> return processLoopStoreOfLoopLoad(Dest, Source, SE->getSCEV(SizeInBytes),
> ```
> ?
Yes you are right. This way better shows this is an NFC.


================
Comment at: llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp:1247
+
+  const SCEV *StoreSizeSCEV = SE->getConstant(StorePtr->getType(), StoreSize);
+  return processLoopStoreOfLoopLoad(StorePtr, LoadPtr, StoreSizeSCEV,
----------------
bmahjour wrote:
> StorePtr->getType() is the type of the pointer, did you mean `SI->getValueOperand()->getType()`? 
The `StoreSizeSCEV` would be used to calculate base address of the pointer if the loop is in negative stride. So its type should be the same with `SI->getPointerOperand()`, which is equivalent to `StorePtr->getType()`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108289/new/

https://reviews.llvm.org/D108289



More information about the llvm-commits mailing list