[PATCH] D152772: [LoopSink] Allow sinking to PHI-use

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 10:24:54 PDT 2023


wenlei marked 2 inline comments as done.
wenlei added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopSink.cpp:194
+    BasicBlock *PhiBB = nullptr;
+    for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
+      Value *PhiVal = PN->getIncomingValue(i);
----------------
nikic wrote:
> wenlei wrote:
> > nikic wrote:
> > > You don't need this loop, use `PN->getIncomingBlock(U)` instead.
> > We need to find all incoming blocks of a value, but `PN->getIncomingBlock(U)` only return one (first) instance? The loop doesn't "break" when a value is found. 
> > 
> > E.g. for value %326, we need to find the 4 incoming blocks for all 4 uses in the PHI. 
> > 
> > ```
> > %343         = phi i64 [ %326, %338 ], [ %291, %305 ], [ %326, %332 ], [ %326, %334 ], [ %326, %337 ]
> > ```
> The outer loop already iterates over all uses. The other phi operands will be visited by it later.
Ah, I see what you meant. Changed - thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152772



More information about the llvm-commits mailing list