[llvm] [CodeGen] Add widening support for ISD::CTTZ_ELTS (PR #205841)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 30 00:24:41 PDT 2026
================
@@ -8723,6 +8727,20 @@ SDValue DAGTypeLegalizer::WidenVecOp_VSELECT(SDNode *N) {
return DAG.getExtractSubvector(DL, VT, Select, 0);
}
+SDValue DAGTypeLegalizer::WidenVecOp_CttzElements(SDNode *N) {
+ SDLoc DL(N);
+ SDValue Source = N->getOperand(0);
+ EVT WideVT = GetWidenedVector(Source).getValueType();
+
+ // Pad the widened portion with all-ones so the extra lanes appear as
+ // active (non-zero) elements and do not contribute trailing zeros.
+ SDValue AllOnes = DAG.getAllOnesConstant(DL, WideVT);
+ SDValue WideSource = DAG.getInsertSubvector(DL, AllOnes, Source, 0);
+
+ return DAG.getNode(N->getOpcode(), DL, N->getValueType(0), WideSource,
+ N->getFlags());
----------------
lukel97 wrote:
For CTTZ_ELTS_ZERO_POISON I don't think we need to pad the widened lanes as zero, it should be fine if they're undefined. But we can do that as a follow up.
https://github.com/llvm/llvm-project/pull/205841
More information about the llvm-commits
mailing list