[llvm] [SelectionDAG] Avoid irregular INSERT_SUBVECTOR when widening CTTZ_ELTS (PR #218019)

Oscar Priego via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 10:47:37 PDT 2026


================
@@ -8722,7 +8722,19 @@ SDValue DAGTypeLegalizer::WidenVecOp_CttzElements(SDNode *N) {
     // 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);
-    WideSource = DAG.getInsertSubvector(DL, AllOnes, Source, 0);
+    if (WideVT.isFixedLengthVector() &&
+        SourceVT.getVectorElementType() == MVT::i1 &&
----------------
Opriego wrote:

Good point. No, I don't think the MVT::i1 restriction is necessary. I originally kept this narrowly scoped to i1 because that's the sub-byte case that exposed the INSERT_SUBVECTOR stack fallback assertion, but the shuffle construction itself is element-type agnostic: it preserves the original lanes and replaces only the widened padding lanes with all-ones. I'll drop the i1 restriction and validate the non-i1 widening cases as well.

https://github.com/llvm/llvm-project/pull/218019


More information about the llvm-commits mailing list