• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -march=nvptx | FileCheck %s
2
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]
6
7define 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
13  ret void
14}
15
16define 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
23  ret void
24}
25
26define 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
33  ret void
34}
35
36define void @test_extend32(half addrspace(1)* %in, float addrspace(1)* %out) {
37; CHECK-LABEL: @test_extend32
38; CHECK: cvt.f32.f16
39
40  %val16 = load half, half addrspace(1)* %in
41  %val32 = fpext half %val16 to float
42  store float %val32, float addrspace(1)* %out
43  ret void
44}
45
46define void @test_extend64(half addrspace(1)* %in, double addrspace(1)* %out) {
47; CHECK-LABEL: @test_extend64
48; CHECK: cvt.f64.f16
49
50  %val16 = load half, half addrspace(1)* %in
51  %val64 = fpext half %val16 to double
52  store double %val64, double addrspace(1)* %out
53  ret void
54}
55
56define void @test_trunc32(float addrspace(1)* %in, half addrspace(1)* %out) {
57; CHECK-LABEL: test_trunc32
58; CHECK: cvt.rn.f16.f32
59
60  %val32 = load float, float addrspace(1)* %in
61  %val16 = fptrunc float %val32 to half
62  store half %val16, half addrspace(1)* %out
63  ret void
64}
65
66define void @test_trunc64(double addrspace(1)* %in, half addrspace(1)* %out) {
67; CHECK-LABEL: @test_trunc64
68; CHECK: cvt.rn.f16.f64
69
70  %val32 = load double, double addrspace(1)* %in
71  %val16 = fptrunc double %val32 to half
72  store half %val16, half addrspace(1)* %out
73  ret void
74}
75