[llvm] [LoopInterchange] Improve profitability check for vectorization (PR #133672)

Ryotaro Kasuga via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 11:18:25 PDT 2025


================
@@ -276,11 +320,12 @@ static bool isLegalToInterChangeLoops(CharMatrix &DepMatrix,
       continue;
 
     // Check if the direction vector is lexicographically positive (or zero)
-    // for both before/after exchanged.
-    if (isLexicographicallyPositive(Cur, OuterLoopId, Cur.size()) == false)
+    // for both before/after exchanged. Ignore the last element because it
+    // doesn't affect the legality.
----------------
kasuga-fj wrote:

Ignoring any elements inside `InnerLoopId` seems true to me.  However,  I think it is necessary to check the  direction vector before interchanging, e.g., when it is `[* <]`. I guess it probably works as a guard for potentially negative vectors.

https://github.com/llvm/llvm-project/pull/133672


More information about the llvm-commits mailing list