[llvm] [SDAG] Fix incorrect usage of VECREDUCE_ADD (PR #171459)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 11 08:35:39 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:
Do you know if `LoMask.getValueType()` is anything other than a vector of i1s here?
I ask because it looks like the offset calculation is either assuming that's the case or perhaps the mask is of ZeroOrOneBooleanContent format. The former is likely true with the current minimal usage but should not be relied on because nodes can come from anywhere. The latter is only going to be true for some targets and is definitely wrong for NEON which uses ZeroOrNegativeOneBooleanContent.
You've not caused this so I don't expect you to fix it but do you mind adding a relevant assert?
https://github.com/llvm/llvm-project/pull/171459
More information about the llvm-commits
mailing list