[llvm] [LoopInterchange] Improve profitability check for vectorization (PR #133672)
Ryotaro Kasuga via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 23 06:12:10 PDT 2025
================
@@ -180,10 +197,22 @@ static bool populateDependencyMatrix(CharMatrix &DepMatrix, unsigned Level,
// Track Output, Flow, and Anti dependencies.
if (auto D = DI->depends(Src, Dst)) {
assert(D->isOrdered() && "Expected an output, flow or anti dep.");
+ bool IsForward = true;
+
+ // If Src and Dst are in the same BB, Src is always executed before Dst
+ // in the same loop iteration. If not, we must check whether one BB
+ // dominates the other to determine if Src and Dst are executed in this
+ // order. At the moment, we don't perform such check.
+ if (Src->getParent() != Dst->getParent())
+ IsForward = false;
+
// If the direction vector is negative, normalize it to
// make it non-negative.
- if (D->normalize(SE))
+ bool Normalized = D->normalize(SE);
+ if (Normalized) {
LLVM_DEBUG(dbgs() << "Negative dependence vector normalized.\n");
+ IsForward = false;
----------------
kasuga-fj wrote:
Thanks for your opinion! This is something I've been thinking about lately, and I don't intend to include this change in the current patch. As the discussion touched on a similar topic, I took the opportunity to raise a related question, just in case you happen to know any background or historical context behind it. Since there appear to be multiple approaches and potentially some edge cases, I'll give it some more thought. Your input was really helpful, thanks again!
> `*` might also mean "sometimes <, sometimes >" depending on control flow. In that case there is no single correct normlization of the dependence vector
Considering this, it makes me wonder if the existence of the function `normalize` might be a bit misleading...
https://github.com/llvm/llvm-project/pull/133672
More information about the llvm-commits
mailing list