[llvm] [VPlan] Compute the cost for vector icmp and fcmp (PR #193268)

John Brawn via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 09:52:28 PDT 2026


================
@@ -1257,6 +1257,15 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
     return Ctx.TTI.getIndexedVectorInstrCostFromEnd(Instruction::ExtractElement,
                                                     VecTy, Ctx.CostKind, 0);
   }
+  case Instruction::FCmp:
+  case Instruction::ICmp:
+    // FIXME: We don't handle scalar compares here yet. Scalar compares used for
+    // the loop exit condition are handled by the legacy cost model, but other
+    // scalar compares (e.g. in the middle block deciding whether to execute the
+    // scalar epilogue) aren't accounted for.
+    if (vputils::onlyFirstLaneUsed(this))
+      return 0;
----------------
john-brawn-arm wrote:

I'm not sure how what you're saying relates to the code here? This PR is just for adding the cost for vector compares, because I was asked for that in https://github.com/llvm/llvm-project/pull/156864/changes#r3117958531. The FIXME is just an explanation of why we would also want to do this for scalar compares (i.e. why #156864 is a good idea).

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


More information about the llvm-commits mailing list