[PATCH] D37076: [LICM] Allow sinking when foldable in loop

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 2 13:51:20 PDT 2017


hfinkel added inline comments.


================
Comment at: lib/Transforms/Scalar/LICM.cpp:715
+  if (GEP && isa<LoadInst>(UserI) && (I->getParent() == UserI->getParent())) {
+    SmallVector<const Value *, 4> Indices;
+    for (auto I = GEP->idx_begin(); I != GEP->idx_end(); ++I)
----------------
hfinkel wrote:
> This can just be:
> 
>   return TTI->getUserCost(GEP) == TargetTransformInfo::TCC_Free;
> 
> (this code here to call getGEPCost seems to duplicate the implementation logic of getUserCost)
> 
> On that note, you might not even have to restrict this to GEPs used by Loads, but rather, you could allow all zero-cost instructions.
(Also, I think that using all 'Free' instructions has the benefit of being correlated with the unrolling cost of the loop - these are the instructions that won't increase the unrolling cost of the loop).


https://reviews.llvm.org/D37076





More information about the llvm-commits mailing list