[llvm] [RISCV][TTI] Implement cost of llvm.experimental.vector.extract.last.active (PR #184067)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 19:46:32 PST 2026
================
@@ -1702,6 +1702,35 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
CmpInst::FCMP_UNO, CostKind);
return Cost;
}
+ case Intrinsic::experimental_vector_extract_last_active: {
+ Type *ValTy = ICA.getArgTypes()[0];
+ Type *MaskTy = ICA.getArgTypes()[1];
+
+ auto ValLT = getTypeLegalizationCost(ValTy);
+ auto MaskLT = getTypeLegalizationCost(MaskTy);
+
+ if (!ValLT.first.isValid() || !MaskLT.first.isValid())
+ return InstructionCost::getInvalid();
+
+ // TODO: Return cheaper cost when the entire lane is inactive.
+ // The expected asm sequence is:
+ // vcpop.m a0, v0
+ // beqz a0, exit # Return passthru when the entire lane is inactive.
+ // vid v10, v0.t
+ // vredmaxu.vs v10, v10, v10
+ // vmv.x.s a0, v10
+ // zext.b a0, a0
+ // vslidedown v8, v8, a0
----------------
lukel97 wrote:
Nit
```suggestion
// vslidedown.vx v8, v8, a0
```
https://github.com/llvm/llvm-project/pull/184067
More information about the llvm-commits
mailing list