1 ; RUN: llc < %s -asm-verbose=0 -mtriple=arm64-eabi -mattr=+bf16 | FileCheck %s
2 ; RUN: llc < %s -asm-verbose=0 -mtriple=aarch64 -mattr=+bf16 | FileCheck %s
4 ; test argument passing and simple load/store
6 define bfloat @test_load(ptr %p) nounwind {
7 ; CHECK-LABEL: test_load:
8 ; CHECK-NEXT: ldr h0, [x0]
10 %tmp1 = load bfloat, ptr %p, align 16
14 define bfloat @test_load_offset1(ptr %p) nounwind {
15 ; CHECK-LABEL: test_load_offset1:
16 ; CHECK-NEXT: ldur h0, [x0, #1]
18 %g = getelementptr inbounds i8, ptr %p, i64 1
19 %tmp1 = load bfloat, ptr %g, align 2
23 define bfloat @test_load_offset2(ptr %p) nounwind {
24 ; CHECK-LABEL: test_load_offset2:
25 ; CHECK-NEXT: ldr h0, [x0, #2]
27 %g = getelementptr inbounds i8, ptr %p, i64 2
28 %tmp1 = load bfloat, ptr %g, align 2
32 define <4 x bfloat> @test_vec_load(ptr %p) nounwind {
33 ; CHECK-LABEL: test_vec_load:
34 ; CHECK-NEXT: ldr d0, [x0]
36 %tmp1 = load <4 x bfloat>, ptr %p, align 16
37 ret <4 x bfloat> %tmp1
40 define void @test_store(ptr %a, bfloat %b) nounwind {
41 ; CHECK-LABEL: test_store:
42 ; CHECK-NEXT: str h0, [x0]
44 store bfloat %b, ptr %a, align 16
48 define void @test_store_negative_offset(ptr %a, bfloat %b) nounwind {
49 ; CHECK-LABEL: test_store_negative_offset:
50 ; CHECK-NEXT: stur h0, [x0, #-4]
53 %0 = getelementptr inbounds bfloat, ptr %a, i64 -2
54 store bfloat %b, ptr %0, align 2
58 ; Simple store of v4bf16
59 define void @test_vec_store(ptr %a, <4 x bfloat> %b) nounwind {
60 ; CHECK-LABEL: test_vec_store:
61 ; CHECK-NEXT: str d0, [x0]
64 store <4 x bfloat> %b, ptr %a, align 16
68 define <8 x bfloat> @test_build_vector_const() {
69 ; CHECK-LABEL: test_build_vector_const:
70 ; CHECK: mov [[TMP:w[0-9]+]], #16256
71 ; CHECK: dup v0.8h, [[TMP]]
72 ret <8 x bfloat> <bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80>
75 define { bfloat, ptr } @test_store_post(bfloat %val, ptr %ptr) {
76 ; CHECK-LABEL: test_store_post:
77 ; CHECK: str h0, [x0], #2
79 store bfloat %val, ptr %ptr
80 %res.tmp = insertvalue { bfloat, ptr } undef, bfloat %val, 0
82 %next = getelementptr bfloat, ptr %ptr, i32 1
83 %res = insertvalue { bfloat, ptr } %res.tmp, ptr %next, 1
85 ret { bfloat, ptr } %res
88 define { <4 x bfloat>, ptr } @test_store_post_v4bf16(<4 x bfloat> %val, ptr %ptr) {
89 ; CHECK-LABEL: test_store_post_v4bf16:
90 ; CHECK: str d0, [x0], #8
92 store <4 x bfloat> %val, ptr %ptr
93 %res.tmp = insertvalue { <4 x bfloat>, ptr } undef, <4 x bfloat> %val, 0
95 %next = getelementptr <4 x bfloat>, ptr %ptr, i32 1
96 %res = insertvalue { <4 x bfloat>, ptr } %res.tmp, ptr %next, 1
98 ret { <4 x bfloat>, ptr } %res
101 define { <8 x bfloat>, ptr } @test_store_post_v8bf16(<8 x bfloat> %val, ptr %ptr) {
102 ; CHECK-LABEL: test_store_post_v8bf16:
103 ; CHECK: str q0, [x0], #16
105 store <8 x bfloat> %val, ptr %ptr
106 %res.tmp = insertvalue { <8 x bfloat>, ptr } undef, <8 x bfloat> %val, 0
108 %next = getelementptr <8 x bfloat>, ptr %ptr, i32 1
109 %res = insertvalue { <8 x bfloat>, ptr } %res.tmp, ptr %next, 1
111 ret { <8 x bfloat>, ptr } %res
114 define bfloat @test_bitcast_halftobfloat(half %a) nounwind {
115 ; CHECK-LABEL: test_bitcast_halftobfloat:
117 %r = bitcast half %a to bfloat
121 define half @test_bitcast_bfloattohalf(bfloat %a) nounwind {
122 ; CHECK-LABEL: test_bitcast_bfloattohalf:
124 %r = bitcast bfloat %a to half