Skip to content

Commit 280b470

Browse files
davemgreentomtor
authored andcommitted
[AArch64] Enable aggressivelyPreferBuildVectorSources (llvm#142729)
This helps to remove some inefficient buildvector lowering by converting extract_vector_elt(buildvector) to the original source.
1 parent 319f923 commit 280b470

16 files changed

+2316
-3952
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ class AArch64TargetLowering : public TargetLowering {
449449
/// Enable aggressive FMA fusion on targets that want it.
450450
bool enableAggressiveFMAFusion(EVT VT) const override;
451451

452+
bool aggressivelyPreferBuildVectorSources(EVT VecVT) const override {
453+
return true;
454+
}
455+
452456
/// Returns the size of the platform's va_list object.
453457
unsigned getVaListSizeInBits(const DataLayout &DL) const override;
454458

llvm/test/CodeGen/AArch64/GlobalISel/combine-build-vector.mir

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,9 @@ body: |
5555
; CHECK-NEXT: {{ $}}
5656
; CHECK-NEXT: %arg1:_(s64) = COPY $x0
5757
; CHECK-NEXT: %arg2:_(s64) = COPY $x1
58-
; CHECK-NEXT: %zero:_(s64) = G_CONSTANT i64 0
59-
; CHECK-NEXT: %one:_(s64) = G_CONSTANT i64 1
6058
; CHECK-NEXT: %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
61-
; CHECK-NEXT: %extract:_(s64) = G_EXTRACT_VECTOR_ELT %bv(<2 x s64>), %zero(s64)
62-
; CHECK-NEXT: %extract2:_(s64) = G_EXTRACT_VECTOR_ELT %bv(<2 x s64>), %one(s64)
63-
; CHECK-NEXT: $x0 = COPY %extract(s64)
64-
; CHECK-NEXT: $x1 = COPY %extract2(s64)
59+
; CHECK-NEXT: $x0 = COPY %arg1(s64)
60+
; CHECK-NEXT: $x1 = COPY %arg2(s64)
6561
; CHECK-NEXT: $q0 = COPY %bv(<2 x s64>)
6662
; CHECK-NEXT: RET_ReallyLR implicit $x0
6763
%arg1:_(s64) = COPY $x0

llvm/test/CodeGen/AArch64/GlobalISel/combine-extract-vec-elt.mir

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,8 @@ body: |
175175
; CHECK-NEXT: {{ $}}
176176
; CHECK-NEXT: %arg1:_(s64) = COPY $x0
177177
; CHECK-NEXT: %arg2:_(s64) = COPY $x1
178-
; CHECK-NEXT: %zero:_(s64) = G_CONSTANT i64 0
179178
; CHECK-NEXT: %bv:_(<2 x s64>) = G_BUILD_VECTOR %arg1(s64), %arg2(s64)
180-
; CHECK-NEXT: %extract:_(s64) = G_EXTRACT_VECTOR_ELT %bv(<2 x s64>), %zero(s64)
181-
; CHECK-NEXT: $x0 = COPY %extract(s64)
179+
; CHECK-NEXT: $x0 = COPY %arg1(s64)
182180
; CHECK-NEXT: $q0 = COPY %bv(<2 x s64>)
183181
; CHECK-NEXT: RET_ReallyLR implicit $x0
184182
%arg1:_(s64) = COPY $x0

llvm/test/CodeGen/AArch64/GlobalISel/combine-insert-vec-elt.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ body: |
278278
; CHECK: liveins: $x0
279279
; CHECK-NEXT: {{ $}}
280280
; CHECK-NEXT: [[C:%[0-9]+]]:_(s8) = G_CONSTANT i8 127
281-
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
282281
; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<32 x s8>) = G_BUILD_VECTOR [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8), [[C]](s8)
282+
; CHECK-NEXT: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
283283
; CHECK-NEXT: G_STORE [[BUILD_VECTOR]](<32 x s8>), [[COPY]](p0) :: (store (<32 x s8>))
284284
; CHECK-NEXT: RET_ReallyLR
285285
%3:_(s8) = G_CONSTANT i8 127

0 commit comments

Comments
 (0)