[llvm] DAG: Fix vector bin op scalarize defining a partially undef vector (PR #122459)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 08:57:28 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))) {
----------------
arsenm wrote:
Actually in the next commit I find a miscompile from this, something is wrong
https://github.com/llvm/llvm-project/pull/122459
More information about the llvm-commits
mailing list