[llvm] [LV][VPlan] Add initial support for CSA vectorization (PR #106560)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 15:04:50 PDT 2024


================
@@ -866,14 +879,23 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
           continue;
         }
 
-        // As a last resort, coerce the PHI to a AddRec expression
-        // and re-try classifying it a an induction PHI.
+        // Try to coerce the PHI to a AddRec expression and re-try classifying
+        // it a an induction PHI.
         if (InductionDescriptor::isInductionPHI(Phi, TheLoop, PSE, ID, true) &&
             !IsDisallowedStridedPointerInduction(ID)) {
           addInductionPhi(Phi, ID, AllowedExit);
           continue;
         }
 
+        // Check if the PHI can be classified as a CSA PHI.
+        if (EnableCSA || (TTI->enableCSAVectorization() &&
+                          EnableCSA.getNumOccurrences() == 0)) {
----------------
michaelmaitland wrote:

https://www.llvm.org/doxygen/classllvm_1_1cl_1_1Option.html#a2dc75fafb68e7669e776e19da7857cdf

This if statement has the following semantics: 
* True if EnableCSA was true by default (it isn't currently)
* True if `enable-csa-vectorization=true` was passed
* True if the subtarget enables CSA by default and it `-enable-csa-vectorization=false` wasn't passed

This gives us the following behaviors:
* Take whatever enable-csa-vectorization is set as if it was passed
* Else defer to subtarget to tell us whether they want csa enabled by default


https://github.com/llvm/llvm-project/pull/106560


More information about the llvm-commits mailing list