Skip to content

Commit 625ee25

Browse files
committed
DAG: Avoid breaking legal vector_shuffle with multiple uses
Previously this combine would undo AMDGPU's new custom legalization of wide vector shuffles into 2 element pieces. The comment also states that this combine is only done before legalization, but the case with a build_vector source was unconditional. We probably don't want to do this if the multiple uses are full scalarization of the vector, but this seems to work well enough. Scalarizing extracts should have folded out pre-legalize.
1 parent 4e1bdb4 commit 625ee25

10 files changed

+1763
-2325
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23185,6 +23185,11 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) {
2318523185
}
2318623186

2318723187
if (SVInVec.getOpcode() == ISD::BUILD_VECTOR) {
23188+
// TODO: Check if shuffle mask is legal?
23189+
if (LegalOperations && TLI.isOperationLegal(ISD::VECTOR_SHUFFLE, VecVT) &&
23190+
!VecOp.hasOneUse())
23191+
return SDValue();
23192+
2318823193
SDValue InOp = SVInVec.getOperand(OrigElt);
2318923194
if (InOp.getValueType() != ScalarVT) {
2319023195
assert(InOp.getValueType().isInteger() && ScalarVT.isInteger());

llvm/test/CodeGen/AMDGPU/shufflevector.v4f32.v2f32.ll

Lines changed: 114 additions & 166 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/shufflevector.v4f32.v3f32.ll

Lines changed: 129 additions & 143 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/shufflevector.v4f32.v4f32.ll

Lines changed: 343 additions & 466 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/shufflevector.v4i32.v2i32.ll

Lines changed: 114 additions & 166 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/shufflevector.v4i32.v3i32.ll

Lines changed: 129 additions & 143 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/shufflevector.v4i32.v4i32.ll

Lines changed: 343 additions & 466 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/shufflevector.v4p3.v2p3.ll

Lines changed: 114 additions & 166 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/shufflevector.v4p3.v3p3.ll

Lines changed: 129 additions & 143 deletions
Large diffs are not rendered by default.

llvm/test/CodeGen/AMDGPU/shufflevector.v4p3.v4p3.ll

Lines changed: 343 additions & 466 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)