Skip to content

Commit c058eb9

Browse files
committed
[AArch64] Fix crash when neither Neon nor SVE are enabled
The subtarget was unconditionally reporting that SVE was to be used to lower vectors when Neon was unavailable, even when SVE itself was unavailable. This decision leads other parts of the compiler to crash, e.g., when querying SVE vector sizes. Reviewed By: sdesmalen Differential Revision: https://reviews.llvm.org/D158179
1 parent 3fee76c commit c058eb9

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

llvm/lib/Target/AArch64/AArch64Subtarget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
394394

395395
bool useSVEForFixedLengthVectors() const {
396396
if (!isNeonAvailable())
397-
return true;
397+
return hasSVE();
398398

399399
// Prefer NEON unless larger SVE registers are available.
400400
return hasSVE() && getMinSVEVectorSizeInBits() >= 256;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
2+
; RUN: opt < %s -passes="print<cost-model>" 2>&1 -disable-output | FileCheck %s
3+
4+
target triple = "aarch64-unknown-linux-gnu"
5+
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
6+
7+
define void @uitofp() #0 {
8+
; CHECK-LABEL: 'uitofp'
9+
; CHECK-NEXT: Cost Model: Found an estimated cost of 16 for instruction: %conv = uitofp <16 x i64> undef to <16 x float>
10+
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
11+
;
12+
%conv = uitofp <16 x i64> undef to <16 x float>
13+
ret void
14+
}
15+
16+
attributes #0 = { "target-features"="-neon" }
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=aarch64-linux-gnu -mattr=-neon < %s | FileCheck %s
3+
4+
target triple = "aarch64-unknown-linux-gnu-elf"
5+
6+
define <16 x float> @foo(<16 x i64> %a) {
7+
; CHECK-LABEL: foo:
8+
; CHECK: // %bb.0:
9+
; CHECK-NEXT: ldp x10, x9, [sp, #48]
10+
; CHECK-NEXT: ldp x12, x11, [sp, #32]
11+
; CHECK-NEXT: ucvtf s1, x10
12+
; CHECK-NEXT: ucvtf s0, x9
13+
; CHECK-NEXT: ldp x13, x9, [sp, #16]
14+
; CHECK-NEXT: ucvtf s2, x11
15+
; CHECK-NEXT: ucvtf s3, x12
16+
; CHECK-NEXT: ldp x11, x10, [sp]
17+
; CHECK-NEXT: str s0, [x8, #60]
18+
; CHECK-NEXT: ucvtf s0, x13
19+
; CHECK-NEXT: str s1, [x8, #56]
20+
; CHECK-NEXT: ucvtf s4, x9
21+
; CHECK-NEXT: str s2, [x8, #52]
22+
; CHECK-NEXT: ucvtf s2, x11
23+
; CHECK-NEXT: str s3, [x8, #48]
24+
; CHECK-NEXT: ucvtf s1, x10
25+
; CHECK-NEXT: ucvtf s3, x7
26+
; CHECK-NEXT: str s0, [x8, #40]
27+
; CHECK-NEXT: ucvtf s0, x5
28+
; CHECK-NEXT: str s4, [x8, #44]
29+
; CHECK-NEXT: ucvtf s4, x6
30+
; CHECK-NEXT: str s2, [x8, #32]
31+
; CHECK-NEXT: ucvtf s2, x3
32+
; CHECK-NEXT: str s1, [x8, #36]
33+
; CHECK-NEXT: ucvtf s1, x4
34+
; CHECK-NEXT: str s3, [x8, #28]
35+
; CHECK-NEXT: ucvtf s3, x2
36+
; CHECK-NEXT: str s4, [x8, #24]
37+
; CHECK-NEXT: ucvtf s4, x1
38+
; CHECK-NEXT: str s0, [x8, #20]
39+
; CHECK-NEXT: ucvtf s0, x0
40+
; CHECK-NEXT: str s1, [x8, #16]
41+
; CHECK-NEXT: str s2, [x8, #12]
42+
; CHECK-NEXT: str s3, [x8, #8]
43+
; CHECK-NEXT: str s4, [x8, #4]
44+
; CHECK-NEXT: str s0, [x8]
45+
; CHECK-NEXT: ret
46+
%conv1 = uitofp <16 x i64> %a to <16 x float>
47+
ret <16 x float> %conv1
48+
}

0 commit comments

Comments
 (0)