1 ; RUN: llc < %s -march=nvptx64 | FileCheck %s
2 ; RUN: %if ptxas %{ llc < %s -march=nvptx64 | %ptxas-verify %}
4 ; CHECK: .b8 half_array[8] = {1, 2, 3, 4, 5, 6, 7, 8};
5 @"half_array" = addrspace(1) constant [4 x half]
6 [half 0xH0201, half 0xH0403, half 0xH0605, half 0xH0807]
8 define void @test_load_store(ptr addrspace(1) %in, ptr addrspace(1) %out) {
9 ; CHECK-LABEL: @test_load_store
10 ; CHECK: ld.global.b16 [[TMP:%rs[0-9]+]], [{{%rd[0-9]+}}]
11 ; CHECK: st.global.b16 [{{%rd[0-9]+}}], [[TMP]]
12 %val = load half, ptr addrspace(1) %in
13 store half %val, ptr addrspace(1) %out
17 define void @test_bitcast_from_half(ptr addrspace(1) %in, ptr addrspace(1) %out) {
18 ; CHECK-LABEL: @test_bitcast_from_half
19 ; CHECK: ld.global.b16 [[TMP:%rs[0-9]+]], [{{%rd[0-9]+}}]
20 ; CHECK: st.global.b16 [{{%rd[0-9]+}}], [[TMP]]
21 %val = load half, ptr addrspace(1) %in
22 %val_int = bitcast half %val to i16
23 store i16 %val_int, ptr addrspace(1) %out
27 define void @test_bitcast_to_half(ptr addrspace(1) %out, ptr addrspace(1) %in) {
28 ; CHECK-LABEL: @test_bitcast_to_half
29 ; CHECK: ld.global.u16 [[TMP:%rs[0-9]+]], [{{%rd[0-9]+}}]
30 ; CHECK: st.global.u16 [{{%rd[0-9]+}}], [[TMP]]
31 %val = load i16, ptr addrspace(1) %in
32 %val_fp = bitcast i16 %val to half
33 store half %val_fp, ptr addrspace(1) %out
37 define void @test_extend32(ptr addrspace(1) %in, ptr addrspace(1) %out) {
38 ; CHECK-LABEL: @test_extend32
41 %val16 = load half, ptr addrspace(1) %in
42 %val32 = fpext half %val16 to float
43 store float %val32, ptr addrspace(1) %out
47 define void @test_extend64(ptr addrspace(1) %in, ptr addrspace(1) %out) {
48 ; CHECK-LABEL: @test_extend64
51 %val16 = load half, ptr addrspace(1) %in
52 %val64 = fpext half %val16 to double
53 store double %val64, ptr addrspace(1) %out
57 define void @test_trunc32(ptr addrspace(1) %in, ptr addrspace(1) %out) {
58 ; CHECK-LABEL: test_trunc32
59 ; CHECK: cvt.rn.f16.f32
61 %val32 = load float, ptr addrspace(1) %in
62 %val16 = fptrunc float %val32 to half
63 store half %val16, ptr addrspace(1) %out
67 define void @test_trunc64(ptr addrspace(1) %in, ptr addrspace(1) %out) {
68 ; CHECK-LABEL: @test_trunc64
69 ; CHECK: cvt.rn.f16.f64
71 %val32 = load double, ptr addrspace(1) %in
72 %val16 = fptrunc double %val32 to half
73 store half %val16, ptr addrspace(1) %out