Skip to content

Commit 4325fd7

Browse files
[AArch64ISelLowering] Don't look through scalable extract_subvector when optimising DUPLANE.
When constructDup is passed an extract_subvector it tries to use extract_subvector's operand directly when creating the DUPLANE. This is invalid when extracting from a scalable vector because the necessary DUPLANE ISel patterns do not exist. NOTE: This patch is an update to https://reviews.llvm.org/D110524 that originally fixed this but introduced a bug when the result VT is 64bits. I've restructured the code so the critial final else block is entered when necessary. Differential Revision: https://reviews.llvm.org/D116442
1 parent 3dc1907 commit 4325fd7

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9631,14 +9631,12 @@ static SDValue constructDup(SDValue V, int Lane, SDLoc dl, EVT VT,
96319631
MVT CastVT;
96329632
if (getScaledOffsetDup(V, Lane, CastVT)) {
96339633
V = DAG.getBitcast(CastVT, V.getOperand(0).getOperand(0));
9634-
} else if (V.getOpcode() == ISD::EXTRACT_SUBVECTOR) {
9634+
} else if (V.getOpcode() == ISD::EXTRACT_SUBVECTOR &&
9635+
V.getOperand(0).getValueType().is128BitVector()) {
96359636
// The lane is incremented by the index of the extract.
96369637
// Example: dup v2f32 (extract v4f32 X, 2), 1 --> dup v4f32 X, 3
9637-
auto VecVT = V.getOperand(0).getValueType();
9638-
if (VecVT.isFixedLengthVector() && VecVT.getFixedSizeInBits() <= 128) {
9639-
Lane += V.getConstantOperandVal(1);
9640-
V = V.getOperand(0);
9641-
}
9638+
Lane += V.getConstantOperandVal(1);
9639+
V = V.getOperand(0);
96429640
} else if (V.getOpcode() == ISD::CONCAT_VECTORS) {
96439641
// The lane is decremented if we are splatting from the 2nd operand.
96449642
// Example: dup v4i32 (concat v2i32 X, v2i32 Y), 3 --> dup v4i32 Y, 1

llvm/test/CodeGen/AArch64/sve-fixed-length-limit-duplane.ll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,27 @@ entry:
2626
store <16 x i32> %2, <16 x i32>* %arg1, align 256
2727
ret <4 x i32> %shvec
2828
}
29+
30+
define <2 x i32> @test2(<16 x i32>* %arg1, <16 x i32>* %arg2) {
31+
; CHECK-LABEL: test2:
32+
; CHECK: // %bb.0: // %entry
33+
; CHECK-NEXT: mov x8, #8
34+
; CHECK-NEXT: ptrue p0.s, vl8
35+
; CHECK-NEXT: ld1w { z1.s }, p0/z, [x0, x8, lsl #2]
36+
; CHECK-NEXT: ld1w { z2.s }, p0/z, [x0]
37+
; CHECK-NEXT: mov z0.d, z1.d
38+
; CHECK-NEXT: add z2.s, p0/m, z2.s, z2.s
39+
; CHECK-NEXT: ext z0.b, z0.b, z1.b, #24
40+
; CHECK-NEXT: add z1.s, p0/m, z1.s, z1.s
41+
; CHECK-NEXT: dup v0.2s, v0.s[0]
42+
; CHECK-NEXT: st1w { z1.s }, p0, [x0, x8, lsl #2]
43+
; CHECK-NEXT: st1w { z2.s }, p0, [x0]
44+
; CHECK-NEXT: ret
45+
entry:
46+
%0 = load <16 x i32>, <16 x i32>* %arg1, align 256
47+
%1 = load <16 x i32>, <16 x i32>* %arg2, align 256
48+
%shvec = shufflevector <16 x i32> %0, <16 x i32> %1, <2 x i32> <i32 14, i32 14>
49+
%2 = add <16 x i32> %0, %0
50+
store <16 x i32> %2, <16 x i32>* %arg1, align 256
51+
ret <2 x i32> %shvec
52+
}

0 commit comments

Comments
 (0)