[llvm] [VPlan] Add transformation to narrow interleave groups. (PR #106441)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 17:01:28 PST 2025


================
@@ -1994,3 +1997,124 @@ void VPlanTransforms::handleUncountableEarlyExit(
   Builder.createNaryOp(VPInstruction::BranchOnCond, AnyExitTaken);
   LatchExitingBranch->eraseFromParent();
 }
+
+static bool supportedLoad(VPWidenRecipe *R0, VPValue *V, unsigned Idx) {
+  if (auto *W = dyn_cast_or_null<VPWidenLoadRecipe>(V->getDefiningRecipe()))
+    return !W->getMask() && (R0->getOperand(0) == V || R0->getOperand(1) == V);
+
+  if (auto *IR = dyn_cast_or_null<VPInterleaveRecipe>(V->getDefiningRecipe()))
+    return IR->getInterleaveGroup()->getFactor() ==
+               IR->getInterleaveGroup()->getNumMembers() &&
+           IR->getVPValue(Idx) == V;
----------------
ayalz wrote:

All IR's are checked to be "consecutive" when collecting StoreGroups in narrowInterleaveGroups(), including all load IR's. So here IR's factor is known to be equal to |members|. Moreover, both are known to be equal to VF. Implying that IR defines at-least Idx(+1) values, so it's ok to getVPValue(Idx).

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


More information about the llvm-commits mailing list