Skip to content

Commit 7a43921

Browse files
authored
[AArch64][SVE] Fix -msve-vector-bits=256 fixed width vector crash (#171776)
This adds tests for and fixes an issue where v8bf16 ISD::FP_ROUND v8f32 cannot be lowered when -msve-vector-bits=256.
1 parent 7345233 commit 7a43921

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,7 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
18781878
// 128bit results imply a bigger than NEON input.
18791879
for (auto VT : {MVT::v16i8, MVT::v8i16, MVT::v4i32})
18801880
setOperationAction(ISD::TRUNCATE, VT, Custom);
1881-
for (auto VT : {MVT::v8f16, MVT::v4f32})
1881+
for (auto VT : {MVT::v8f16, MVT::v4f32, MVT::v8bf16})
18821882
setOperationAction(ISD::FP_ROUND, VT, Custom);
18831883

18841884
// These operations are not supported on NEON but SVE can do them.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2+
; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
3+
4+
define <8 x bfloat> @fptrunc_v8bf16(<8 x float> %a) #0 {
5+
; CHECK-LABEL: fptrunc_v8bf16:
6+
; CHECK: // %bb.0:
7+
; CHECK-NEXT: ptrue p0.d, vl2
8+
; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
9+
; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
10+
; CHECK-NEXT: splice z0.d, p0, z0.d, z1.d
11+
; CHECK-NEXT: ptrue p0.s
12+
; CHECK-NEXT: bfcvt z0.h, p0/m, z0.s
13+
; CHECK-NEXT: uzp1 z0.h, z0.h, z0.h
14+
; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
15+
; CHECK-NEXT: ret
16+
%fpt = fptrunc <8 x float> %a to <8 x bfloat>
17+
ret <8 x bfloat> %fpt
18+
}
19+
20+
define <8 x half> @fptrunc_v8f16(<8 x float> %a) #0 {
21+
; CHECK-LABEL: fptrunc_v8f16:
22+
; CHECK: // %bb.0:
23+
; CHECK-NEXT: ptrue p0.d, vl2
24+
; CHECK-NEXT: // kill: def $q0 killed $q0 def $z0
25+
; CHECK-NEXT: // kill: def $q1 killed $q1 def $z1
26+
; CHECK-NEXT: splice z0.d, p0, z0.d, z1.d
27+
; CHECK-NEXT: ptrue p0.s
28+
; CHECK-NEXT: fcvt z0.h, p0/m, z0.s
29+
; CHECK-NEXT: uzp1 z0.h, z0.h, z0.h
30+
; CHECK-NEXT: // kill: def $q0 killed $q0 killed $z0
31+
; CHECK-NEXT: ret
32+
%fpt = fptrunc <8 x float> %a to <8 x half>
33+
ret <8 x half> %fpt
34+
}
35+
36+
attributes #0 = { vscale_range(2,2) "target-features"="+bf16,+sve" }

0 commit comments

Comments
 (0)