[llvm] [Analysis] Extend llvm.experimental.cttz.elts to type-based-cost (PR #184578)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 8 21:32:32 PDT 2026
https://github.com/lukel97 commented:
I took a bit of a closer look at this and I'm not sure if this is the right fix. Mainly because we already dedicated code for costing cttz.elts in RISCVTargetTransformInfo, and this is fixing the BasicTTIImpl code which we shouldn't have to fall back to.
I think the root cause for that crash is that we should be splitting those illegal types like v2048i1, but we don't have any type legalization for cttz_elts. I.e. we shouldn't be returning true for RISCVTargetLowering::shouldExpandCttzElements when the type isn't legal, we should just let LegalizeTypes take care of it. But cttz.elts doesn't have a dedicated SelectionDAG node, even though we have nodes for VP_CTTZ_ELTS[_ZERO_UNDEF].
I can submit some patches to start legalizing this properly, but in the meantime I think a better solution is probably to just workaround this in RISCVTargetTransformInfo. Can we return InstructionCost::getInvalid() when the type is illegal for now to avoid the crashing? That would also avoid the AArch64 changes
https://github.com/llvm/llvm-project/pull/184578
More information about the llvm-commits
mailing list