[llvm] [LV] Cost EVL width-adjusting zext/trunc as free (PR #225016)
Pengcheng Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 03:58:49 PDT 2026
================
@@ -1360,9 +1360,17 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
// NOTE: At the moment it seems only possible to expose this path for
// the trunc, zext and sext opcodes.
// TODO: Update VF arg to use onlyFirstLaneUsed once WidenCast is unified.
- if (Instruction::isCast(getOpcode()))
+ if (Instruction::isCast(getOpcode())) {
+ // A scalar zext/trunc that only adjusts the width of an
+ // ExplicitVectorLength to the canonical IV type is free: it feeds only
+ // the IV increment and AVL decrement, which are modeled as free below.
+ if ((getOpcode() == Instruction::ZExt ||
+ getOpcode() == Instruction::Trunc) &&
+ match(getOperand(0), m_EVL(m_VPValue())))
+ return 0;
----------------
wangpc-pp wrote:
Done in https://github.com/llvm/llvm-project/pull/225016/commits/11dc1b8c240059bf82a77185052e3f99d4347dd5.
https://github.com/llvm/llvm-project/pull/225016
More information about the llvm-commits
mailing list