File: f16-abs.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,388 kB
  • sloc: cpp: 7,438,767; ansic: 1,393,871; asm: 1,012,926; python: 241,728; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (98 lines) | stat: -rw-r--r-- 4,356 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5

; ## FP16 abs is not supported by PTX version (PTX < 65).
; RUN: llc < %s -mcpu=sm_53 -mattr=+ptx60                                      \
; RUN:          -O0 -disable-post-ra -verify-machineinstrs                     \
; RUN: | FileCheck -check-prefix CHECK-NOF16 %s
; RUN: %if ptxas %{                                                            \
; RUN:   llc < %s -mcpu=sm_53 -mattr=+ptx60                                    \
; RUN:            -O0 -disable-post-ra -verify-machineinstrs                   \
; RUN:   | %ptxas-verify -arch=sm_53                                           \
; RUN: %}

; ## FP16 support explicitly disabled (--nvptx-no-f16-math).
; RUN: llc < %s -mcpu=sm_53 -mattr=+ptx65 --nvptx-no-f16-math                  \
; RUN:          -O0 -disable-post-ra -verify-machineinstrs                     \
; RUN: | FileCheck -check-prefix CHECK-NOF16 %s
; RUN: %if ptxas %{                                                            \
; RUN:   llc < %s -mcpu=sm_53 -mattr=+ptx65 --nvptx-no-f16-math                \
; RUN:            -O0 -disable-post-ra -verify-machineinstrs                   \
; RUN:   | %ptxas-verify -arch=sm_53                                           \
; RUN: %}

; ## FP16 is not supported by hardware (SM < 53).
; RUN: llc < %s -mcpu=sm_52 -mattr=+ptx65                                      \
; RUN:          -O0 -disable-post-ra -verify-machineinstrs                     \
; RUN: | FileCheck -check-prefix CHECK-NOF16 %s
; RUN: %if ptxas %{                                                            \
; RUN:   llc < %s -mcpu=sm_52 -mattr=+ptx65                                    \
; RUN:          -O0 -disable-post-ra -verify-machineinstrs                     \
; RUN:   | %ptxas-verify -arch=sm_52                                           \
; RUN: %}

; ## Full FP16 abs support.
; RUN: llc < %s -mcpu=sm_53 -mattr=+ptx65                                      \
; RUN:          -O0 -disable-post-ra -verify-machineinstrs                     \
; RUN: | FileCheck -check-prefix CHECK-F16-ABS %s
; RUN: %if ptxas %{                                                            \
; RUN:   llc < %s -mcpu=sm_53 -mattr=+ptx65                                    \
; RUN:          -O0 -disable-post-ra -verify-machineinstrs                     \
; RUN:   | %ptxas-verify -arch=sm_53                                           \
; RUN: %}

target triple = "nvptx64-nvidia-cuda"

declare half @llvm.fabs.f16(half %a)
declare <2 x half> @llvm.fabs.v2f16(<2 x half> %a)

define half @test_fabs(half %a) {
; CHECK-NOF16-LABEL: test_fabs(
; CHECK-NOF16:       {
; CHECK-NOF16-NEXT:    .reg .b16 %rs<3>;
; CHECK-NOF16-NEXT:    .reg .f32 %f<3>;
; CHECK-NOF16-EMPTY:
; CHECK-NOF16-NEXT:  // %bb.0:
; CHECK-NOF16-NEXT:    ld.param.b16 %rs1, [test_fabs_param_0];
; CHECK-NOF16-NEXT:    cvt.f32.f16 %f1, %rs1;
; CHECK-NOF16-NEXT:    abs.f32 %f2, %f1;
; CHECK-NOF16-NEXT:    cvt.rn.f16.f32 %rs2, %f2;
; CHECK-NOF16-NEXT:    st.param.b16 [func_retval0], %rs2;
; CHECK-NOF16-NEXT:    ret;
;
; CHECK-F16-ABS-LABEL: test_fabs(
; CHECK-F16-ABS:       {
; CHECK-F16-ABS-NEXT:    .reg .b16 %rs<3>;
; CHECK-F16-ABS-EMPTY:
; CHECK-F16-ABS-NEXT:  // %bb.0:
; CHECK-F16-ABS-NEXT:    ld.param.b16 %rs1, [test_fabs_param_0];
; CHECK-F16-ABS-NEXT:    abs.f16 %rs2, %rs1;
; CHECK-F16-ABS-NEXT:    st.param.b16 [func_retval0], %rs2;
; CHECK-F16-ABS-NEXT:    ret;
  %r = call half @llvm.fabs.f16(half %a)
  ret half %r
}

define <2 x half> @test_fabs_2(<2 x half> %a) #0 {
; CHECK-F16-LABEL: test_fabs_2(
; CHECK-F16:       {
; CHECK-F16-NEXT:    .reg .b32 %r<5>;
; CHECK-F16-EMPTY:
; CHECK-F16-NEXT:  // %bb.0:
; CHECK-F16-NEXT:    ld.param.b32 %r1, [test_fabs_2_param_0];
; CHECK-F16-NEXT:    and.b32 %r3, %r1, 2147450879;
; CHECK-F16-NEXT:    st.param.b32 [func_retval0], %r3;
; CHECK-F16-NEXT:    ret;
;
; CHECK-F16-ABS-LABEL: test_fabs_2(
; CHECK-F16-ABS:       {
; CHECK-F16-ABS-NEXT:    .reg .b32 %r<3>;
; CHECK-F16-ABS-EMPTY:
; CHECK-F16-ABS-NEXT:  // %bb.0:
; CHECK-F16-ABS-NEXT:    ld.param.b32 %r1, [test_fabs_2_param_0];
; CHECK-F16-ABS-NEXT:    abs.f16x2 %r2, %r1;
; CHECK-F16-ABS-NEXT:    st.param.b32 [func_retval0], %r2;
; CHECK-F16-ABS-NEXT:    ret;
  %r = call <2 x half> @llvm.fabs.v2f16(<2 x half> %a)
  ret <2 x half> %r
}