[llvm] [TTI][RISCV]Improve costs for whole vector reg extract/insert. (PR #80164)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 21 08:03:06 PST 2024
================
@@ -442,6 +454,9 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
return LT.first *
getRISCVInstructionCost(RISCV::VSLIDEDOWN_VI, LT.second, CostKind);
case TTI::SK_InsertSubvector:
+ if (Index == 0 && !Args.empty() && any_of(Args, UndefValue::classof))
----------------
preames wrote:
I tried to split off this piece - or more accurately something vaguely related - and stumbled into something interesting.
The InsertSubvector w/Index=0 is unreachable from everywhere except SLP. TTI::getInstructionCost contains a check for the identity shuffle and always returns 0. improveShuffleKindFromMask will recognize the insert into passthru case as a select (correctly), and thus it doesn't hit this case either. Put together, this means that the index=0 case never makes it from the backend, and thus we have no test coverage via cost model tests.
SLP hits a slightly different codepath here and directly calls getShuffleCost with a possible identity mask. It still can't hit the select case, but it can hit the insert into poison case. SLP appears to have a bunch of guards for this already in various cases.
I'm not really a fan of having untestable logic here. Anyone have any ideas how we can rework this API to ensure SLP can't reach a case which is untestable via costmodel tests?
https://github.com/llvm/llvm-project/pull/80164
More information about the llvm-commits
mailing list