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

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 11:02:54 PDT 2024


================
@@ -60,3 +60,30 @@ bool vputils::isHeaderMask(const VPValue *V, VPlan &Plan) {
   return match(V, m_Binary<Instruction::ICmp>(m_VPValue(A), m_VPValue(B))) &&
          IsWideCanonicalIV(A) && B == Plan.getOrCreateBackedgeTakenCount();
 }
+
+bool vputils::isPhi(const VPRecipeBase &R) {
+  if (R.isPhi())
+    return true;
+  if (auto *VPInst = dyn_cast<VPInstruction>(&R))
+    return VPInst->getOpcode() == VPInstruction::CSAMaskPhi ||
+           VPInst->getOpcode() == VPInstruction::CSAVLPhi;
+  return false;
+}
+
+bool vputils::isPhiThatGeneratesBackedge(const VPRecipeBase &R) {
+  if (isa<VPWidenPHIRecipe, VPCSAHeaderPHIRecipe>(&R))
+    return true;
+  if (auto *VPInst = dyn_cast<VPInstruction>(&R))
+    return VPInst->getOpcode() == VPInstruction::CSAMaskPhi ||
+           VPInst->getOpcode() == VPInstruction::CSAVLPhi;
+  return false;
+}
+
+bool vputils::isHeaderPhi(const VPRecipeBase &R) {
+  if (isa<VPHeaderPHIRecipe, VPWidenPHIRecipe>(&R))
+    return true;
+  if (auto *VPInst = dyn_cast<VPInstruction>(&R))
+    return VPInst->getOpcode() == VPInstruction::CSAMaskPhi ||
+           VPInst->getOpcode() == VPInstruction::CSAVLPhi;
+  return false;
----------------
michaelmaitland wrote:

I have refactored this code

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


More information about the llvm-commits mailing list