Skip to content

Commit 3529cc4

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 1c0f60a commit 3529cc4

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

2317423174
if (SVInVec.getOpcode() == ISD::BUILD_VECTOR) {
23175+
// TODO: Check if shuffle mask is legal?
23176+
if (LegalOperations && TLI.isOperationLegal(ISD::VECTOR_SHUFFLE, VecVT) &&
23177+
!VecOp.hasOneUse())
23178+
return SDValue();
23179+
2317523180
SDValue InOp = SVInVec.getOperand(OrigElt);
2317623181
if (InOp.getValueType() != ScalarVT) {
2317723182
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)