[llvm] DAG: Use poison for unused shuffle operands in legalizer (PR #177578)
Björn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 5 03:12:35 PST 2026
================
@@ -3235,14 +3235,14 @@ void DAGTypeLegalizer::SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N,
processShuffleMasks(
Mask, std::size(Inputs), std::size(Inputs),
/*NumOfUsedRegs=*/1,
- [&Output, &DAG = DAG, NewVT]() { Output = DAG.getUNDEF(NewVT); },
+ [&Output, &DAG = DAG, NewVT]() { Output = DAG.getPOISON(NewVT); },
----------------
bjope wrote:
I think this is wrong in some way (see https://github.com/llvm/llvm-project/issues/179448).
The analysis earlier in this function is doing things like
```
if (Inputs[SrcRegIdx].isUndef()) {
Idx = PoisonMaskElem;
continue;
}
```
And isUndef is matching both UNDEF and POISON. Not sure exactly what happens, but maybe we make the vector more poisonous by using POISON here rather than UNDEF.
The miscompile in #179448 seems to go away if using UNDEF here. But it also go away if changing the ifUndef checks earlier in this function to only check for ISD::POISON. There are however lots of things going on with PoisonMaskElem, isUndef() etc above, as well as more changes from getUNDEF to getPOISON further down. So there could be multiple issues.
I guess that we need to use UNDEF here if we found UNDEF when peeking through shuffles etc. above.
https://github.com/llvm/llvm-project/pull/177578
More information about the llvm-commits
mailing list