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

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue May 14 05:36:11 PDT 2024


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

>From 67c18fe6ca0d491bde18dc7f8e7c6e32e52f4dbb Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <r at artagnon.com>
Date: Thu, 9 May 2024 15:35:59 +0100
Subject: [PATCH 1/3] [DO NOT COMMIT] Enable assertions for
 compile-time-tracker

---
 llvm/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index c06e661573ed4..9ce1f8e0997e6 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -624,7 +624,7 @@ option(LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled
 option(LLVM_UNREACHABLE_OPTIMIZE "Optimize llvm_unreachable() as undefined behavior (default), guaranteed trap when OFF" ON)
 
 if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
-  option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)
+  option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
 else()
   option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
 endif()

>From cbfebd1b531f905efde60c913c9dd35b6b161019 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 2/3] 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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 261933966b74b..67641f753ce17 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;
 }
 
@@ -10318,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
@@ -10347,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();
@@ -10359,6 +10357,8 @@ LoopVectorizeResult LoopVectorizePass::runImpl(
     }
   }
 
+  assert(!ToVectorize || !verifyFunction(F, &dbgs()));
+
   // Process each loop nest in the function.
   return LoopVectorizeResult(Changed, CFGChanged);
 }

>From 2c13f873b5c44ed651728723bbf83e34f97e7f33 Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <r at artagnon.com>
Date: Tue, 14 May 2024 13:35:18 +0100
Subject: [PATCH 3/3] Revert "[DO NOT COMMIT] Enable assertions for
 compile-time-tracker"

This reverts commit 67c18fe6ca0d491bde18dc7f8e7c6e32e52f4dbb.
---
 llvm/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 9ce1f8e0997e6..c06e661573ed4 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -624,7 +624,7 @@ option(LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled
 option(LLVM_UNREACHABLE_OPTIMIZE "Optimize llvm_unreachable() as undefined behavior (default), guaranteed trap when OFF" ON)
 
 if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
-  option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
+  option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)
 else()
   option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
 endif()



More information about the llvm-commits mailing list