annotate llvm/test/CodeGen/AMDGPU/cvt_rpi_i32_f32.ll @ 252:1f2b6ac9f198 llvm-original

LLVM16-1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Fri, 18 Aug 2023 09:04:13 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI-SAFE -check-prefix=SI -check-prefix=FUNC %s
anatofuz
parents:
diff changeset
2 ; RUN: llc -march=amdgcn -enable-no-nans-fp-math -verify-machineinstrs < %s | FileCheck -check-prefix=SI-NONAN -check-prefix=SI -check-prefix=FUNC %s
anatofuz
parents:
diff changeset
3 ; RUN: llc -march=amdgcn -mcpu=tonga < %s | FileCheck -check-prefix=SI-SAFE -check-prefix=SI -check-prefix=FUNC %s
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 declare float @llvm.fabs.f32(float) #1
anatofuz
parents:
diff changeset
6 declare float @llvm.floor.f32(float) #1
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 ; FUNC-LABEL: {{^}}cvt_rpi_i32_f32:
anatofuz
parents:
diff changeset
9 ; SI-SAFE-NOT: v_cvt_rpi_i32_f32
anatofuz
parents:
diff changeset
10 ; SI-NONAN: v_cvt_rpi_i32_f32_e32 v{{[0-9]+}}, s{{[0-9]+}}
anatofuz
parents:
diff changeset
11 ; SI: s_endpgm
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
12 define amdgpu_kernel void @cvt_rpi_i32_f32(ptr addrspace(1) %out, float %x) #0 {
150
anatofuz
parents:
diff changeset
13 %fadd = fadd float %x, 0.5
anatofuz
parents:
diff changeset
14 %floor = call float @llvm.floor.f32(float %fadd) #1
anatofuz
parents:
diff changeset
15 %cvt = fptosi float %floor to i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
16 store i32 %cvt, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
17 ret void
anatofuz
parents:
diff changeset
18 }
anatofuz
parents:
diff changeset
19
anatofuz
parents:
diff changeset
20 ; FUNC-LABEL: {{^}}cvt_rpi_i32_f32_fabs:
anatofuz
parents:
diff changeset
21 ; SI-SAFE-NOT: v_cvt_rpi_i32_f32
anatofuz
parents:
diff changeset
22 ; SI-NONAN: v_cvt_rpi_i32_f32_e64 v{{[0-9]+}}, |s{{[0-9]+}}|{{$}}
anatofuz
parents:
diff changeset
23 ; SI: s_endpgm
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
24 define amdgpu_kernel void @cvt_rpi_i32_f32_fabs(ptr addrspace(1) %out, float %x) #0 {
150
anatofuz
parents:
diff changeset
25 %x.fabs = call float @llvm.fabs.f32(float %x) #1
anatofuz
parents:
diff changeset
26 %fadd = fadd float %x.fabs, 0.5
anatofuz
parents:
diff changeset
27 %floor = call float @llvm.floor.f32(float %fadd) #1
anatofuz
parents:
diff changeset
28 %cvt = fptosi float %floor to i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
29 store i32 %cvt, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
30 ret void
anatofuz
parents:
diff changeset
31 }
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 ; FIXME: This doesn't work because it forms fsub 0.5, x
anatofuz
parents:
diff changeset
34 ; FUNC-LABEL: {{^}}cvt_rpi_i32_f32_fneg:
anatofuz
parents:
diff changeset
35 ; XSI-NONAN: v_cvt_rpi_i32_f32_e64 v{{[0-9]+}}, -s{{[0-9]+}}
anatofuz
parents:
diff changeset
36 ; SI: v_sub_f32_e64 [[TMP:v[0-9]+]], 0.5, s{{[0-9]+}}
anatofuz
parents:
diff changeset
37 ; SI-SAFE-NOT: v_cvt_flr_i32_f32
anatofuz
parents:
diff changeset
38 ; SI-NONAN: v_cvt_flr_i32_f32_e32 {{v[0-9]+}}, [[TMP]]
anatofuz
parents:
diff changeset
39 ; SI: s_endpgm
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
40 define amdgpu_kernel void @cvt_rpi_i32_f32_fneg(ptr addrspace(1) %out, float %x) #0 {
150
anatofuz
parents:
diff changeset
41 %x.fneg = fsub float -0.000000e+00, %x
anatofuz
parents:
diff changeset
42 %fadd = fadd float %x.fneg, 0.5
anatofuz
parents:
diff changeset
43 %floor = call float @llvm.floor.f32(float %fadd) #1
anatofuz
parents:
diff changeset
44 %cvt = fptosi float %floor to i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
45 store i32 %cvt, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
46 ret void
anatofuz
parents:
diff changeset
47 }
anatofuz
parents:
diff changeset
48
anatofuz
parents:
diff changeset
49 ; FIXME: This doesn't work for same reason as above
anatofuz
parents:
diff changeset
50 ; FUNC-LABEL: {{^}}cvt_rpi_i32_f32_fabs_fneg:
anatofuz
parents:
diff changeset
51 ; SI-SAFE-NOT: v_cvt_rpi_i32_f32
anatofuz
parents:
diff changeset
52 ; XSI-NONAN: v_cvt_rpi_i32_f32_e64 v{{[0-9]+}}, -|s{{[0-9]+}}|
anatofuz
parents:
diff changeset
53
anatofuz
parents:
diff changeset
54 ; SI: v_sub_f32_e64 [[TMP:v[0-9]+]], 0.5, |s{{[0-9]+}}|
anatofuz
parents:
diff changeset
55 ; SI-SAFE-NOT: v_cvt_flr_i32_f32
anatofuz
parents:
diff changeset
56 ; SI-NONAN: v_cvt_flr_i32_f32_e32 {{v[0-9]+}}, [[TMP]]
anatofuz
parents:
diff changeset
57 ; SI: s_endpgm
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
58 define amdgpu_kernel void @cvt_rpi_i32_f32_fabs_fneg(ptr addrspace(1) %out, float %x) #0 {
150
anatofuz
parents:
diff changeset
59 %x.fabs = call float @llvm.fabs.f32(float %x) #1
anatofuz
parents:
diff changeset
60 %x.fabs.fneg = fsub float -0.000000e+00, %x.fabs
anatofuz
parents:
diff changeset
61 %fadd = fadd float %x.fabs.fneg, 0.5
anatofuz
parents:
diff changeset
62 %floor = call float @llvm.floor.f32(float %fadd) #1
anatofuz
parents:
diff changeset
63 %cvt = fptosi float %floor to i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
64 store i32 %cvt, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
65 ret void
anatofuz
parents:
diff changeset
66 }
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 ; FUNC-LABEL: {{^}}no_cvt_rpi_i32_f32_0:
anatofuz
parents:
diff changeset
69 ; SI-NOT: v_cvt_rpi_i32_f32
anatofuz
parents:
diff changeset
70 ; SI: v_add_f32
anatofuz
parents:
diff changeset
71 ; SI: v_floor_f32
anatofuz
parents:
diff changeset
72 ; SI: v_cvt_u32_f32
anatofuz
parents:
diff changeset
73 ; SI: s_endpgm
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
74 define amdgpu_kernel void @no_cvt_rpi_i32_f32_0(ptr addrspace(1) %out, float %x) #0 {
150
anatofuz
parents:
diff changeset
75 %fadd = fadd float %x, 0.5
anatofuz
parents:
diff changeset
76 %floor = call float @llvm.floor.f32(float %fadd) #1
anatofuz
parents:
diff changeset
77 %cvt = fptoui float %floor to i32
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
78 store i32 %cvt, ptr addrspace(1) %out
150
anatofuz
parents:
diff changeset
79 ret void
anatofuz
parents:
diff changeset
80 }
anatofuz
parents:
diff changeset
81
anatofuz
parents:
diff changeset
82 attributes #0 = { nounwind }
anatofuz
parents:
diff changeset
83 attributes #1 = { nounwind readnone }