[llvm] [SelectionDAG] Expand CTTZ_ELTS[_ZERO_POISON] and handle legalization (PR #188691)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 30 03:44:43 PDT 2026


================
@@ -1221,6 +1225,18 @@ SDValue DAGTypeLegalizer::ScalarizeVecOp_VECTOR_FIND_LAST_ACTIVE(SDNode *N) {
   return DAG.getConstant(0, SDLoc(N), VT);
 }
 
+SDValue DAGTypeLegalizer::ScalarizeVecOp_CTTZ_ELTS(SDNode *N) {
+  // The number of trailing zero elements is 1 if the element is 0, and 0
+  // otherwise.
+  if (N->getOpcode() == ISD::CTTZ_ELTS_ZERO_POISON)
+    return DAG.getConstant(0, SDLoc(N), N->getValueType(0));
+  SDValue Op = GetScalarizedVector(N->getOperand(0));
+  SDValue SetCC =
+      DAG.getSetCC(SDLoc(N), MVT::i1, Op,
----------------
david-arm wrote:

Shouldn't this use `TLI.getSetCCResultType` instead of `MVT::i1`? See ScalarizeVecRes_LOOP_DEPENDENCE_MASK as an example.

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


More information about the llvm-commits mailing list