Skip to content

Commit f9ada5a

Browse files
committed
Just use insert_vector_elt
1 parent f83583a commit f9ada5a

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27532,18 +27532,11 @@ static SDValue scalarizeBinOpOfSplats(SDNode *N, SelectionDAG &DAG,
2753227532

2753327533
// If all lanes but 1 are undefined, no need to splat the scalar result.
2753427534
// TODO: Keep track of undefs and use that info in the general case.
27535-
if (N0.getOpcode() == ISD::BUILD_VECTOR && N0.getOpcode() == N1.getOpcode() &&
27536-
// This is assuming if either input is undef, the result will fold out.
27537-
//
27538-
// TODO: Do we need to check if the opcode/operand propagates undef?
27539-
// Should we ignore operation identity values?
27540-
((count_if(N0->ops(), [](SDValue V) { return !V.isUndef(); }) == 1) ||
27541-
(count_if(N1->ops(), [](SDValue V) { return !V.isUndef(); }) == 1))) {
27535+
if (N0.getOpcode() == ISD::BUILD_VECTOR && N0.getOpcode() == N1.getOpcode()) {
2754227536
// bo (build_vec ..undef, X, undef...), (build_vec ..undef, Y, undef...) -->
27543-
// build_vec ..undef, (bo X, Y), undef...
27544-
SmallVector<SDValue, 8> Ops(VT.getVectorNumElements(), DAG.getUNDEF(EltVT));
27545-
Ops[Index0] = ScalarBO;
27546-
return DAG.getBuildVector(VT, DL, Ops);
27537+
// insert_vector_elt undef, (bo X, Y), index
27538+
return DAG.getNode(ISD::INSERT_VECTOR_ELT, DL, VT, DAG.getUNDEF(VT),
27539+
ScalarBO, IndexC);
2754727540
}
2754827541

2754927542
// bo (splat X, Index), (splat Y, Index) --> splat (bo X, Y), Index

0 commit comments

Comments
 (0)