Skip to content

Commit 0f588c8

Browse files
committed
Cleanup and comment
1 parent 7cd9367 commit 0f588c8

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Diff for: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

+11-10
Original file line numberDiff line numberDiff line change
@@ -23811,6 +23811,7 @@ SDValue DAGCombiner::reduceBuildVecToShuffle(SDNode *N) {
2381123811
// value.
2381223812
unsigned OneConstExtractIndex = ~0u;
2381323813

23814+
// Count the number of extract_vector_elt sources (i.e. non-constant or undef)
2381423815
unsigned NumExtracts = 0;
2381523816

2381623817
for (unsigned i = 0; i != NumElems; ++i) {
@@ -23849,9 +23850,7 @@ SDValue DAGCombiner::reduceBuildVecToShuffle(SDNode *N) {
2384923850
ExtractedFromVec.getValueType().getVectorElementType())
2385023851
return SDValue();
2385123852

23852-
if (OneConstExtractIndex == ~0u)
23853-
OneConstExtractIndex = ExtractIdx->getZExtValue();
23854-
23853+
OneConstExtractIndex = ExtractIdx->getZExtValue();
2385523854
++NumExtracts;
2385623855

2385723856
// Have we seen this input vector before?
@@ -23878,14 +23877,16 @@ SDValue DAGCombiner::reduceBuildVecToShuffle(SDNode *N) {
2387823877
if (VecIn.size() == 2) {
2387923878
// If we only found a single constant indexed extract_vector_elt feeding the
2388023879
// build_vector, do not produce a more complicated shuffle if the extract is
23881-
// cheap.
23882-
23883-
// TODO: This should be more aggressive about skipping the shuffle formation
23884-
// (e.g., always do this for VecIn[1]->hasOneUse())
23885-
if (TLI.isOperationLegalOrCustom(ISD::EXTRACT_VECTOR_ELT, VT) &&
23880+
// cheap with other constant/undef elements. Skip broadcast patterns with
23881+
// multiple uses in the build_vector.
23882+
23883+
// TODO: This should be more aggressive about skipping the shuffle
23884+
// formation, particularly if VecIn[1].hasOneUse(), and regardless of the
23885+
// index.
23886+
if (NumExtracts == 1 &&
23887+
TLI.isOperationLegalOrCustom(ISD::EXTRACT_VECTOR_ELT, VT) &&
2388623888
TLI.isTypeLegal(VT.getVectorElementType()) &&
23887-
// VecIn[1].hasOneUse() &&
23888-
NumExtracts == 1 && TLI.isExtractVecEltCheap(VT, OneConstExtractIndex))
23889+
TLI.isExtractVecEltCheap(VT, OneConstExtractIndex))
2388923890
return SDValue();
2389023891

2389123892
unsigned MaxIndex = 0;

0 commit comments

Comments
 (0)