Skip to content

Commit 98936ae

Browse files
committed
[AArch64][SVE] Fix selection failure during lowering of shuffle_vector
The lowering code for shuffle_vector has a code path that looks through extract_subvector, this code path did not properly account for the potential presense of larger than Neon vector types and could produce unselectable DAG nodes. Differential Revision: https://reviews.llvm.org/D119252
1 parent 4517488 commit 98936ae

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9728,6 +9728,10 @@ static SDValue constructDup(SDValue V, int Lane, SDLoc dl, EVT VT,
97289728
if (ExtIdxInBits % CastedEltBitWidth != 0)
97299729
return false;
97309730

9731+
// Can't handle cases where vector size is not 128-bit
9732+
if (!Extract.getOperand(0).getValueType().is128BitVector())
9733+
return false;
9734+
97319735
// Update the lane value by offsetting with the scaled extract index.
97329736
LaneC += ExtIdxInBits / CastedEltBitWidth;
97339737

llvm/test/CodeGen/AArch64/sve-fixed-length-shuffles.ll

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -aarch64-sve-vector-bits-min=256 < %s | FileCheck %s
1+
; RUN: llc < %s | FileCheck %s
22

33
target triple = "aarch64-unknown-linux-gnu"
44

@@ -14,4 +14,22 @@ define void @hang_when_merging_stores_after_legalisation(<8 x i32>* %a, <2 x i32
1414
ret void
1515
}
1616

17-
attributes #0 = { nounwind "target-features"="+sve" }
17+
; Ensure we don't crash when trying to lower a shuffle via and extract
18+
define void @crash_when_lowering_extract_shuffle(<32 x i32>* %dst, i1 %cond) #0 {
19+
; CHECK-LABEL: crash_when_lowering_extract_shuffle:
20+
; CHECK: ld1w { z3.s }, p0/z, [x0]
21+
; CHECK: st1w { z3.s }, p0, [x0]
22+
%broadcast.splat = shufflevector <32 x i1> zeroinitializer, <32 x i1> zeroinitializer, <32 x i32> zeroinitializer
23+
br i1 %cond, label %exit, label %vector.body
24+
25+
vector.body:
26+
%1 = load <32 x i32>, <32 x i32>* %dst, align 16
27+
%predphi = select <32 x i1> %broadcast.splat, <32 x i32> zeroinitializer, <32 x i32> %1
28+
store <32 x i32> %predphi, <32 x i32>* %dst, align 16
29+
br label %exit
30+
31+
exit:
32+
ret void
33+
}
34+
35+
attributes #0 = { vscale_range(2,2) "target-features"="+sve" }

0 commit comments

Comments
 (0)