[PATCH] D149147: [LoopVectorize] Preserve SCEV

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 25 05:29:13 PDT 2023


nikic created this revision.
nikic added a reviewer: fhahn.
Herald added subscribers: shiva0217, StephenFan, javed.absar, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead.
Herald added a project: LLVM.

As far as I can tell, LoopVectorize preserves SCEV, mainly by dint of forgetting the loop being vectorized. We should mark it as preserved in the pass manager.

This is a very small compile-time improvement: http://llvm-compile-time-tracker.com/compare.php?from=a1677bda7975a0f690292587a04b9e053aacd1dc&to=bb3b36e5587a636f51e59a76d2e26db07ceea9ff&stat=instructions:u


https://reviews.llvm.org/D149147

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


Index: llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll
===================================================================
--- llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll
+++ llvm/test/Transforms/LoopVectorize/novect-lcssa-cfg-invalidation.ll
@@ -8,7 +8,7 @@
 define i32 @novect(ptr %p) {
 
 ; CHECK:           Running pass: LoopVectorizePass on novect
-; CHECK:           Invalidating analysis: ScalarEvolutionAnalysis on novect
+; CHECK-NOT:       Invalidating analysis: ScalarEvolutionAnalysis on novect
 ; CHECK-NOT:       Invalidating analysis: BranchProbabilityAnalysis on novect
 ; CHECK-NOT:       Invalidating analysis: BlockFrequencyAnalysis on novect
 ; CHECK:           Invalidating analysis: DemandedBitsAnalysis on novect
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -10638,6 +10638,11 @@
     if (!EnableVPlanNativePath) {
       PA.preserve<LoopAnalysis>();
       PA.preserve<DominatorTreeAnalysis>();
+      PA.preserve<ScalarEvolutionAnalysis>();
+
+#ifdef EXPENSIVE_CHECKS
+      SE.verify();
+#endif
     }
 
     if (Result.MadeCFGChange) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149147.516756.patch
Type: text/x-patch
Size: 1292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230425/5f6f708b/attachment.bin>


More information about the llvm-commits mailing list