[PATCH] D79418: [LSR][ARM] Add new TTI hook to mark some LSR chains as profitable

Pierre van Houtryve via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 08:01:53 PDT 2020


Pierre-vh added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:2856
+
+  if (TTI.isProfitableLSRChainElement(Chain.Incs[0].UserInst))
+    return true;
----------------
samparker wrote:
> Is this necessary? If this is executed in the loop then I don't see the worth of optimising the first iteration.
It's not executed in the loop below, that one skips the first element, so the first element has to be handled separately.

See IVChain's implementation:
```
struct IVChain {
  SmallVector<IVInc, 1> Incs;
  
   /* ... */

  using const_iterator = SmallVectorImpl<IVInc>::const_iterator;

  // Return the first increment in the chain.
  const_iterator begin() const {
    assert(!Incs.empty());
    return std::next(Incs.begin());
  }
  const_iterator end() const {
    return Incs.end();
  }

  /* ... */
};
``` 


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

https://reviews.llvm.org/D79418





More information about the llvm-commits mailing list