[llvm] DAG: Fix vector bin op scalarize defining a partially undef vector (PR #122459)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 13 04:39:20 PST 2025
================
@@ -27525,8 +27525,12 @@ static SDValue scalarizeBinOpOfSplats(SDNode *N, SelectionDAG &DAG,
// If all lanes but 1 are undefined, no need to splat the scalar result.
// TODO: Keep track of undefs and use that info in the general case.
if (N0.getOpcode() == ISD::BUILD_VECTOR && N0.getOpcode() == N1.getOpcode() &&
- count_if(N0->ops(), [](SDValue V) { return !V.isUndef(); }) == 1 &&
- count_if(N1->ops(), [](SDValue V) { return !V.isUndef(); }) == 1) {
+ // This is assuming if either input is undef, the result will fold out.
+ //
+ // TODO: Do we need to check if the opcode/operand propagates undef?
+ // Should we ignore operation identity values?
+ ((count_if(N0->ops(), [](SDValue V) { return !V.isUndef(); }) == 1) ||
+ (count_if(N1->ops(), [](SDValue V) { return !V.isUndef(); }) == 1))) {
----------------
RKSimon wrote:
The opcode specific under handling does worry me- how well does this work if we completely scalarize all elements and leave getNode() to handle the undefs / constant handling etc? Similar to what getKnownUndefForVectorBinop does in TargetLowering
https://github.com/llvm/llvm-project/pull/122459
More information about the llvm-commits
mailing list