[llvm] [LV][VPlan] Implement VPlan-based cost for exit condition. (PR #125640)
Elvis Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 5 23:06:24 PST 2025
================
@@ -823,6 +823,29 @@ bool VPInstruction::onlyFirstPartUsed(const VPValue *Op) const {
llvm_unreachable("switch should return");
}
+InstructionCost VPInstruction::computeCost(ElementCount VF,
+ VPCostContext &Ctx) const {
+ Type *ValTy = Ctx.Types.inferScalarType(getOperand(0));
+
+ switch (getOpcode()) {
+ case VPInstruction::BranchOnCount: {
----------------
ElvisWang123 wrote:
Agree that `BranchOnCond` will generate `extractelement(vec, 0)` and isn't free for all target. But after this change, the test still change because the extractelement is free under AArch64.
In `clamped_tc_8` the `BranchOnCount` is replaced by `get.active.lane.mask` + `not` + `BranchOnCond`.
I've tried to implement the cost of `get.active.lane.mask` locally but it will impact lots of tests because the cost of this intrinsics is very expensive in AArch64 (2 * element count). And the `clapmed_tc_8` will not even vectorized.
https://github.com/llvm/llvm-project/pull/125640
More information about the llvm-commits
mailing list