Skip to content

Commit 97a1f49

Browse files
authored
DAG: Avoid breaking legal vector_shuffle with multiple uses (#123712)
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 edb7f6c commit 97a1f49

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
@@ -23186,6 +23186,11 @@ SDValue DAGCombiner::visitEXTRACT_VECTOR_ELT(SDNode *N) {
2318623186
}
2318723187

2318823188
if (SVInVec.getOpcode() == ISD::BUILD_VECTOR) {
23189+
// TODO: Check if shuffle mask is legal?
23190+
if (LegalOperations && TLI.isOperationLegal(ISD::VECTOR_SHUFFLE, VecVT) &&
23191+
!VecOp.hasOneUse())
23192+
return SDValue();
23193+
2318923194
SDValue InOp = SVInVec.getOperand(OrigElt);
2319023195
if (InOp.getValueType() != ScalarVT) {
2319123196
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)