[llvm] ac03ae3 - [LV] Preserve LAA in LoopVectorize (NFCI).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 5 13:41:43 PDT 2024


Author: Florian Hahn
Date: 2024-07-05T21:41:31+01:00
New Revision: ac03ae30cf2b6465ea8f117dfa74ba6f670f6258

URL: https://github.com/llvm/llvm-project/commit/ac03ae30cf2b6465ea8f117dfa74ba6f670f6258
DIFF: https://github.com/llvm/llvm-project/commit/ac03ae30cf2b6465ea8f117dfa74ba6f670f6258.diff

LOG: [LV] Preserve LAA in LoopVectorize (NFCI).

LoopVectorize already always preserves DT, LI and SCEV. If any changes
get made to the CFG, cached LAA info for loops are cleared.

LoopAccessAnalysis also implements ::invalidate to clear the analysis if
SE, DT or LI gets invalidated. Hence it should be safe to preserve LAA
and save a small amount of compile-time.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
    llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 56fb8a10d7334..1423deb5a73f9 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10258,6 +10258,7 @@ PreservedAnalyses LoopVectorizePass::run(Function &F,
     PA.preserve<LoopAnalysis>();
     PA.preserve<DominatorTreeAnalysis>();
     PA.preserve<ScalarEvolutionAnalysis>();
+    PA.preserve<LoopAccessAnalysis>();
 
     if (Result.MadeCFGChange) {
       // Making CFG changes likely means a loop got vectorized. Indicate that

diff  --git a/llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll b/llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll
index c78e005311ef2..48fa198620d46 100644
--- a/llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll
+++ b/llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll
@@ -12,7 +12,7 @@ define i32 @novect(ptr %p) {
 ; CHECK-NOT:       Invalidating analysis: BranchProbabilityAnalysis on novect
 ; CHECK-NOT:       Invalidating analysis: BlockFrequencyAnalysis on novect
 ; CHECK:           Invalidating analysis: DemandedBitsAnalysis on novect
-; CHECK:           Invalidating analysis: LoopAccessAnalysis on novect
+; CHECK-NOT:       Invalidating analysis: LoopAccessAnalysis on novect
 ; CHECK:           Running pass: JumpThreadingPass on novect
 
 ; CHECK:           entry:


        


More information about the llvm-commits mailing list