[PATCH] D119683: [LV] Mark induction PHI nodes as allowed exits (NFC).

Ricky Zhou via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 13 17:37:13 PST 2022


rickyz created this revision.
rickyz added a reviewer: fhahn.
Herald added subscribers: rogfer01, javed.absar, hiraditya.
rickyz requested review of this revision.
Herald added subscribers: llvm-commits, vkmr.
Herald added a project: LLVM.

Prior to this change, loop vectorization legality checks only added
induction PHI nodes to AllowedExit (the list of variables which are
allowed to be used outside of the loop) when its SCEV predicates are
alway true. However, this isn't strictly necessary - all necessary
predicates should have held whenever the final value was computed.

This is not expected to cause any functional change. Loop-external IV
uses are already allowed (correctly so, per the above reasoning), since
the existing code never checks induction PHIs against AllowedExit. The
only purpose of this change is to make the code a little easier to
understand by making the contents of AllowedExit consistent with what
the vectorization legality checks allow.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119683

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp


Index: llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -566,14 +566,13 @@
       PrimaryInduction = Phi;
   }
 
-  // Both the PHI node itself, and the "post-increment" value feeding
-  // back into the PHI node may have external users.
-  // We can allow those uses, except if the SCEVs we have for them rely
-  // on predicates that only hold within the loop, since allowing the exit
-  // currently means re-using this SCEV outside the loop (see PR33706 for more
-  // details).
+  // The induction PHI node may have external users.
+  AllowedExit.insert(Phi);
+
+  // Allow external uses of the "post-increment" value feeding back into
+  // the PHI node unless its SCEV relies on predicates that may not hold
+  // outside of the loop (see PR33706 for more details).
   if (PSE.getPredicate().isAlwaysTrue()) {
-    AllowedExit.insert(Phi);
     AllowedExit.insert(Phi->getIncomingValueForBlock(TheLoop->getLoopLatch()));
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119683.408304.patch
Type: text/x-patch
Size: 1145 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220214/7cb29192/attachment.bin>


More information about the llvm-commits mailing list