1 ; RUN: llc < %s -march=nvptx | FileCheck %s
3 ; CHECK: .b8 half_array[8] = {1, 2, 3, 4, 5, 6, 7, 8};
4 @"half_array" = addrspace(1) constant [4 x half]
5 [half 0xH0201, half 0xH0403, half 0xH0605, half 0xH0807]
7 define void @test_load_store(half addrspace(1)* %in, half addrspace(1)* %out) {
8 ; CHECK-LABEL: @test_load_store
9 ; CHECK: ld.global.b16 [[TMP:%h[0-9]+]], [{{%r[0-9]+}}]
10 ; CHECK: st.global.b16 [{{%r[0-9]+}}], [[TMP]]
11 %val = load half, half addrspace(1)* %in
12 store half %val, half addrspace(1) * %out
16 define void @test_bitcast_from_half(half addrspace(1)* %in, i16 addrspace(1)* %out) {
17 ; CHECK-LABEL: @test_bitcast_from_half
18 ; CHECK: ld.global.b16 [[TMP:%h[0-9]+]], [{{%r[0-9]+}}]
19 ; CHECK: st.global.b16 [{{%r[0-9]+}}], [[TMP]]
20 %val = load half, half addrspace(1) * %in
21 %val_int = bitcast half %val to i16
22 store i16 %val_int, i16 addrspace(1)* %out
26 define void @test_bitcast_to_half(half addrspace(1)* %out, i16 addrspace(1)* %in) {
27 ; CHECK-LABEL: @test_bitcast_to_half
28 ; CHECK: ld.global.u16 [[TMP:%rs[0-9]+]], [{{%r[0-9]+}}]
29 ; CHECK: st.global.u16 [{{%r[0-9]+}}], [[TMP]]
30 %val = load i16, i16 addrspace(1)* %in
31 %val_fp = bitcast i16 %val to half
32 store half %val_fp, half addrspace(1)* %out
36 define void @test_extend32(half addrspace(1)* %in, float addrspace(1)* %out) {
37 ; CHECK-LABEL: @test_extend32
40 %val16 = load half, half addrspace(1)* %in
41 %val32 = fpext half %val16 to float
42 store float %val32, float addrspace(1)* %out
46 define void @test_extend64(half addrspace(1)* %in, double addrspace(1)* %out) {
47 ; CHECK-LABEL: @test_extend64
50 %val16 = load half, half addrspace(1)* %in
51 %val64 = fpext half %val16 to double
52 store double %val64, double addrspace(1)* %out
56 define void @test_trunc32(float addrspace(1)* %in, half addrspace(1)* %out) {
57 ; CHECK-LABEL: test_trunc32
58 ; CHECK: cvt.rn.f16.f32
60 %val32 = load float, float addrspace(1)* %in
61 %val16 = fptrunc float %val32 to half
62 store half %val16, half addrspace(1)* %out
66 define void @test_trunc64(double addrspace(1)* %in, half addrspace(1)* %out) {
67 ; CHECK-LABEL: @test_trunc64
68 ; CHECK: cvt.rn.f16.f64
70 %val32 = load double, double addrspace(1)* %in
71 %val16 = fptrunc double %val32 to half
72 store half %val16, half addrspace(1)* %out