[llvm] [LoopVectorize] Add the cost of VPInstruction::AnyOf to vplan (PR #125058)

Hassnaa Hamdi via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 06:50:07 PST 2025


================
@@ -709,6 +709,20 @@ Value *VPInstruction::generate(VPTransformState &State) {
   }
 }
 
+InstructionCost VPInstruction::computeCost(ElementCount VF,
+                                           VPCostContext &Ctx) const {
+  switch (getOpcode()) {
+  case VPInstruction::AnyOf: {
+    auto *VecI1Ty = VectorType::get(Type::getInt1Ty(Ctx.LLVMCtx), VF);
+    return Ctx.TTI.getArithmeticReductionCost(Instruction::Or, VecI1Ty,
----------------
hassnaaHamdi wrote:

Hi Dave,
Is there a reason behind using the reduction cost specifically?

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


More information about the llvm-commits mailing list