[llvm] [SDAG] Fix incorrect usage of VECREDUCE_ADD (PR #171459)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 12 06:14:32 PST 2025


================
@@ -2663,8 +2663,10 @@ void DAGTypeLegalizer::SplitVecRes_VECTOR_COMPRESS(SDNode *N, SDValue &Lo,
       MF, cast<FrameIndexSDNode>(StackPtr.getNode())->getIndex());
 
   // We store LoVec and then insert HiVec starting at offset=|1s| in LoMask.
-  SDValue WideMask =
-      DAG.getNode(ISD::ZERO_EXTEND, DL, LoMask.getValueType(), LoMask);
+  EVT WideMaskVT =
+      EVT::getVectorVT(*DAG.getContext(), MVT::i32,
+                       LoMask.getValueType().getVectorElementCount());
+  SDValue WideMask = DAG.getNode(ISD::ZERO_EXTEND, DL, WideMaskVT, LoMask);
   SDValue Offset = DAG.getNode(ISD::VECREDUCE_ADD, DL, MVT::i32, WideMask);
----------------
paulwalker-arm wrote:

Results are legalised before operands so I'd expect SplitVecRes_VECTOR_COMPRESS to be called before PromoteIntOp_VECTOR_COMPRESS.  We do this because for many operations, legalising the result requires legalising its operands and so only the result side needs to be implemented.

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


More information about the llvm-commits mailing list