1; RUN: llc < %s -asm-verbose=0 -mtriple=arm64-eabi -mattr=+bf16 | FileCheck %s 2; RUN: llc < %s -asm-verbose=0 -mtriple=aarch64-eabi -mattr=+bf16 | FileCheck %s 3 4; test argument passing and simple load/store 5 6define bfloat @test_load(bfloat* %p) nounwind { 7; CHECK-LABEL: test_load: 8; CHECK-NEXT: ldr h0, [x0] 9; CHECK-NEXT: ret 10 %tmp1 = load bfloat, bfloat* %p, align 16 11 ret bfloat %tmp1 12} 13 14define <4 x bfloat> @test_vec_load(<4 x bfloat>* %p) nounwind { 15; CHECK-LABEL: test_vec_load: 16; CHECK-NEXT: ldr d0, [x0] 17; CHECK-NEXT: ret 18 %tmp1 = load <4 x bfloat>, <4 x bfloat>* %p, align 16 19 ret <4 x bfloat> %tmp1 20} 21 22define void @test_store(bfloat* %a, bfloat %b) nounwind { 23; CHECK-LABEL: test_store: 24; CHECK-NEXT: str h0, [x0] 25; CHECK-NEXT: ret 26 store bfloat %b, bfloat* %a, align 16 27 ret void 28} 29 30; Simple store of v4bf16 31define void @test_vec_store(<4 x bfloat>* %a, <4 x bfloat> %b) nounwind { 32; CHECK-LABEL: test_vec_store: 33; CHECK-NEXT: str d0, [x0] 34; CHECK-NEXT: ret 35entry: 36 store <4 x bfloat> %b, <4 x bfloat>* %a, align 16 37 ret void 38} 39 40define <8 x bfloat> @test_build_vector_const() { 41; CHECK-LABEL: test_build_vector_const: 42; CHECK: mov [[TMP:w[0-9]+]], #16256 43; CHECK: dup v0.8h, [[TMP]] 44 ret <8 x bfloat> <bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80, bfloat 0xR3F80> 45} 46 47define { bfloat, bfloat* } @test_store_post(bfloat %val, bfloat* %ptr) { 48; CHECK-LABEL: test_store_post: 49; CHECK: str h0, [x0], #2 50 51 store bfloat %val, bfloat* %ptr 52 %res.tmp = insertvalue { bfloat, bfloat* } undef, bfloat %val, 0 53 54 %next = getelementptr bfloat, bfloat* %ptr, i32 1 55 %res = insertvalue { bfloat, bfloat* } %res.tmp, bfloat* %next, 1 56 57 ret { bfloat, bfloat* } %res 58} 59 60define { <4 x bfloat>, <4 x bfloat>* } @test_store_post_v4bf16(<4 x bfloat> %val, <4 x bfloat>* %ptr) { 61; CHECK-LABEL: test_store_post_v4bf16: 62; CHECK: str d0, [x0], #8 63 64 store <4 x bfloat> %val, <4 x bfloat>* %ptr 65 %res.tmp = insertvalue { <4 x bfloat>, <4 x bfloat>* } undef, <4 x bfloat> %val, 0 66 67 %next = getelementptr <4 x bfloat>, <4 x bfloat>* %ptr, i32 1 68 %res = insertvalue { <4 x bfloat>, <4 x bfloat>* } %res.tmp, <4 x bfloat>* %next, 1 69 70 ret { <4 x bfloat>, <4 x bfloat>* } %res 71} 72 73define { <8 x bfloat>, <8 x bfloat>* } @test_store_post_v8bf16(<8 x bfloat> %val, <8 x bfloat>* %ptr) { 74; CHECK-LABEL: test_store_post_v8bf16: 75; CHECK: str q0, [x0], #16 76 77 store <8 x bfloat> %val, <8 x bfloat>* %ptr 78 %res.tmp = insertvalue { <8 x bfloat>, <8 x bfloat>* } undef, <8 x bfloat> %val, 0 79 80 %next = getelementptr <8 x bfloat>, <8 x bfloat>* %ptr, i32 1 81 %res = insertvalue { <8 x bfloat>, <8 x bfloat>* } %res.tmp, <8 x bfloat>* %next, 1 82 83 ret { <8 x bfloat>, <8 x bfloat>* } %res 84} 85 86define bfloat @test_bitcast_halftobfloat(half %a) nounwind { 87; CHECK-LABEL: test_bitcast_halftobfloat: 88; CHECK-NEXT: ret 89 %r = bitcast half %a to bfloat 90 ret bfloat %r 91} 92 93define half @test_bitcast_bfloattohalf(bfloat %a) nounwind { 94; CHECK-LABEL: test_bitcast_bfloattohalf: 95; CHECK-NEXT: ret 96 %r = bitcast bfloat %a to half 97 ret half %r 98} 99