[llvm] [VectorUtils][VPlan] Consolidate VPWidenIntrinsicRecipe::onlyFirstLaneUsed and isVectorIntrinsicWithScalarOpAtArg (PR #137497)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 12:32:04 PDT 2025


================
@@ -1364,10 +1364,13 @@ StringRef VPWidenIntrinsicRecipe::getIntrinsicName() const {
 
 bool VPWidenIntrinsicRecipe::onlyFirstLaneUsed(const VPValue *Op) const {
   assert(is_contained(operands(), Op) && "Op must be an operand of the recipe");
-  // Vector predication intrinsics only demand the the first lane the last
-  // operand (the EVL operand).
-  return VPIntrinsic::isVPIntrinsic(VectorIntrinsicID) &&
-         Op == getOperand(getNumOperands() - 1);
+  for (auto [Idx, V] : enumerate(operands())) {
+    if (V != Op)
+      continue;
+    if (!isVectorIntrinsicWithScalarOpAtArg(VectorIntrinsicID, Idx, nullptr))
+      return false;
+  }
+  return true;
----------------
fhahn wrote:

can we use `any_of`/`all_of`?

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


More information about the llvm-commits mailing list