[llvm] LoopVectorize: run verifyFunction once (PR #91470)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 07:39:37 PDT 2024


https://github.com/artagnon updated https://github.com/llvm/llvm-project/pull/91470

>From 44a1941f7e26aa0d06943ed6771ffe1b759ec269 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <r at artagnon.com>
Date: Wed, 8 May 2024 13:50:03 +0100
Subject: [PATCH 1/2] LoopVectorize: run verifyFunction once

In an effort to cut compile-times, run verifyFunction once per function
in LoopVectorize, as opposed to running it as many times as there are
loops in the function. The downside of this is that, in cases of a
broken function, the user won't be informed exactly which loop
transformation failed, but this is perhaps an acceptable price to pay
for cutting down compile-times.
---
 llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 261933966b74b..8d9afeabb67e0 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9677,7 +9677,6 @@ static bool processLoopInVPlanNativePath(
 
   // Mark the loop as already vectorized to avoid vectorizing again.
   Hints.setAlreadyVectorized();
-  assert(!verifyFunction(*L->getHeader()->getParent(), &dbgs()));
   return true;
 }
 
@@ -10286,7 +10285,6 @@ bool LoopVectorizePass::processLoop(Loop *L) {
     Hints.setAlreadyVectorized();
   }
 
-  assert(!verifyFunction(*L->getHeader()->getParent(), &dbgs()));
   return true;
 }
 
@@ -10359,6 +10357,8 @@ LoopVectorizeResult LoopVectorizePass::runImpl(
     }
   }
 
+  assert(!Changed || !verifyFunction(F, &dbgs()));
+
   // Process each loop nest in the function.
   return LoopVectorizeResult(Changed, CFGChanged);
 }

>From f4d46252bffb443c1237ba905e8c1603e1a5e48f Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <r at artagnon.com>
Date: Wed, 8 May 2024 15:30:30 +0100
Subject: [PATCH 2/2] LoopVectorize: address review

---
 llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 8d9afeabb67e0..67641f753ce17 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10316,7 +10316,7 @@ LoopVectorizeResult LoopVectorizePass::runImpl(
       TTI->getMaxInterleaveFactor(ElementCount::getFixed(1)) < 2)
     return LoopVectorizeResult(false, false);
 
-  bool Changed = false, CFGChanged = false;
+  bool Changed = false, CFGChanged = false, ToVectorize = false;
 
   // The vectorizer requires loops to be in simplified form.
   // Since simplification may add new inner loops, it has to run before the
@@ -10345,7 +10345,7 @@ LoopVectorizeResult LoopVectorizePass::runImpl(
     // transform.
     Changed |= formLCSSARecursively(*L, *DT, LI, SE);
 
-    Changed |= CFGChanged |= processLoop(L);
+    Changed |= CFGChanged |= ToVectorize |= processLoop(L);
 
     if (Changed) {
       LAIs->clear();
@@ -10357,7 +10357,7 @@ LoopVectorizeResult LoopVectorizePass::runImpl(
     }
   }
 
-  assert(!Changed || !verifyFunction(F, &dbgs()));
+  assert(!ToVectorize || !verifyFunction(F, &dbgs()));
 
   // Process each loop nest in the function.
   return LoopVectorizeResult(Changed, CFGChanged);



More information about the llvm-commits mailing list