Skip to content

Commit 7f518ee

Browse files
authored
[DAG] Add a one-use check to concat -> scalar_to_vector fold. (llvm#79510)
Without this we can end up with multiple copies from gpr->fpr.
1 parent d5fe1bd commit 7f518ee

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23842,7 +23842,7 @@ SDValue DAGCombiner::visitCONCAT_VECTORS(SDNode *N) {
2384223842
}
2384323843

2384423844
// concat_vectors(scalar, undef) -> scalar_to_vector(scalar)
23845-
if (!Scalar.getValueType().isVector()) {
23845+
if (!Scalar.getValueType().isVector() && In.hasOneUse()) {
2384623846
// If the bitcast type isn't legal, it might be a trunc of a legal type;
2384723847
// look through the trunc so we can still do the transform:
2384823848
// concat_vectors(trunc(scalar), undef) -> scalar_to_vector(scalar)

llvm/test/CodeGen/AArch64/pr79100.ll

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,16 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc < %s -mtriple=aarch64 | FileCheck %s --check-prefixes=CHECK,CHECK-SD
3-
; RUN: llc < %s -mtriple=aarch64 -global-isel 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
2+
; RUN: llc < %s -mtriple=aarch64 | FileCheck %s --check-prefixes=CHECK
3+
; RUN: llc < %s -mtriple=aarch64 -global-isel 2>&1 | FileCheck %s --check-prefixes=CHECK
44

55
define <16 x i8> @test_2(i64 %0) {
6-
; CHECK-SD-LABEL: test_2:
7-
; CHECK-SD: // %bb.0: // %Entry
8-
; CHECK-SD-NEXT: fmov d1, x0
9-
; CHECK-SD-NEXT: fmov d2, x0
10-
; CHECK-SD-NEXT: movi v0.16b, #15
11-
; CHECK-SD-NEXT: ushr v1.8b, v1.8b, #4
12-
; CHECK-SD-NEXT: zip1 v1.16b, v2.16b, v1.16b
13-
; CHECK-SD-NEXT: and v0.16b, v1.16b, v0.16b
14-
; CHECK-SD-NEXT: ret
15-
;
16-
; CHECK-GI-LABEL: test_2:
17-
; CHECK-GI: // %bb.0: // %Entry
18-
; CHECK-GI-NEXT: fmov d1, x0
19-
; CHECK-GI-NEXT: movi v0.16b, #15
20-
; CHECK-GI-NEXT: ushr v2.8b, v1.8b, #4
21-
; CHECK-GI-NEXT: zip1 v1.16b, v1.16b, v2.16b
22-
; CHECK-GI-NEXT: and v0.16b, v1.16b, v0.16b
23-
; CHECK-GI-NEXT: ret
6+
; CHECK-LABEL: test_2:
7+
; CHECK: // %bb.0: // %Entry
8+
; CHECK-NEXT: fmov d1, x0
9+
; CHECK-NEXT: movi v0.16b, #15
10+
; CHECK-NEXT: ushr v2.8b, v1.8b, #4
11+
; CHECK-NEXT: zip1 v1.16b, v1.16b, v2.16b
12+
; CHECK-NEXT: and v0.16b, v1.16b, v0.16b
13+
; CHECK-NEXT: ret
2414
Entry:
2515
%1 = bitcast i64 %0 to <8 x i8>
2616
%2 = lshr <8 x i8> %1, <i8 4, i8 4, i8 4, i8 4, i8 4, i8 4, i8 4, i8 4>

0 commit comments

Comments
 (0)