File: fsqrt.f64.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (123 lines) | stat: -rw-r--r-- 4,742 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -global-isel=0 -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
; RUN: llc -global-isel=0 -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s

; RUN: llc -global-isel=1 -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
; RUN: llc -global-isel=1 -march=amdgcn -mcpu=fiji -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s

define double @v_sqrt_f64(double %x) {
; GCN-LABEL: v_sqrt_f64:
; GCN:       ; %bb.0:
; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GCN-NEXT:    v_sqrt_f64_e32 v[0:1], v[0:1]
; GCN-NEXT:    s_setpc_b64 s[30:31]
  %result = call double @llvm.sqrt.f64(double %x)
  ret double %result
}

define double @v_sqrt_f64_fneg(double %x) {
; GCN-LABEL: v_sqrt_f64_fneg:
; GCN:       ; %bb.0:
; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GCN-NEXT:    v_sqrt_f64_e64 v[0:1], -v[0:1]
; GCN-NEXT:    s_setpc_b64 s[30:31]
  %x.neg = fneg double %x
  %result = call double @llvm.sqrt.f64(double %x.neg)
  ret double %result
}

define double @v_sqrt_f64_fabs(double %x) {
; GCN-LABEL: v_sqrt_f64_fabs:
; GCN:       ; %bb.0:
; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GCN-NEXT:    v_sqrt_f64_e64 v[0:1], |v[0:1]|
; GCN-NEXT:    s_setpc_b64 s[30:31]
  %x.fabs = call double @llvm.fabs.f64(double %x)
  %result = call double @llvm.sqrt.f64(double %x.fabs)
  ret double %result
}

define double @v_sqrt_f64_fneg_fabs(double %x) {
; GCN-LABEL: v_sqrt_f64_fneg_fabs:
; GCN:       ; %bb.0:
; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GCN-NEXT:    v_sqrt_f64_e64 v[0:1], -|v[0:1]|
; GCN-NEXT:    s_setpc_b64 s[30:31]
  %x.fabs = call double @llvm.fabs.f64(double %x)
  %x.fabs.neg = fneg double %x.fabs
  %result = call double @llvm.sqrt.f64(double %x.fabs.neg)
  ret double %result
}

define double @v_sqrt_f64_ninf(double %x) {
; GCN-LABEL: v_sqrt_f64_ninf:
; GCN:       ; %bb.0:
; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GCN-NEXT:    v_sqrt_f64_e32 v[0:1], v[0:1]
; GCN-NEXT:    s_setpc_b64 s[30:31]
  %result = call ninf double @llvm.sqrt.f64(double %x)
  ret double %result
}

define double @v_sqrt_f64_no_infs_attribute(double %x) "no-infs-fp-math"="true" {
; GCN-LABEL: v_sqrt_f64_no_infs_attribute:
; GCN:       ; %bb.0:
; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GCN-NEXT:    v_sqrt_f64_e32 v[0:1], v[0:1]
; GCN-NEXT:    s_setpc_b64 s[30:31]
  %result = call ninf double @llvm.sqrt.f64(double %x)
  ret double %result
}

define double @v_sqrt_f64_nnan(double %x) {
; GCN-LABEL: v_sqrt_f64_nnan:
; GCN:       ; %bb.0:
; GCN-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
; GCN-NEXT:    v_sqrt_f64_e32 v[0:1], v[0:1]
; GCN-NEXT:    s_setpc_b64 s[30:31]
  %result = call nnan double @llvm.sqrt.f64(double %x)
  ret double %result
}

define amdgpu_ps <2 x i32> @s_sqrt_f64(double inreg %x) {
; GCN-LABEL: s_sqrt_f64:
; GCN:       ; %bb.0:
; GCN-NEXT:    v_sqrt_f64_e32 v[0:1], s[0:1]
; GCN-NEXT:    v_readfirstlane_b32 s0, v0
; GCN-NEXT:    v_readfirstlane_b32 s1, v1
; GCN-NEXT:    ; return to shader part epilog
  %result = call double @llvm.sqrt.f64(double %x)
  %cast = bitcast double %result to <2 x i32>
  %cast.0 = extractelement <2 x i32> %cast, i32 0
  %cast.1 = extractelement <2 x i32> %cast, i32 1
  %lane.0 = call i32 @llvm.amdgcn.readfirstlane(i32 %cast.0)
  %lane.1 = call i32 @llvm.amdgcn.readfirstlane(i32 %cast.1)
  %insert.0 = insertelement <2 x i32> poison, i32 %lane.0, i32 0
  %insert.1 = insertelement <2 x i32> %insert.0, i32 %lane.1, i32 1
  ret <2 x i32> %insert.1
}

define amdgpu_ps <2 x i32> @s_sqrt_f64_ninf(double inreg %x) {
; GCN-LABEL: s_sqrt_f64_ninf:
; GCN:       ; %bb.0:
; GCN-NEXT:    v_sqrt_f64_e32 v[0:1], s[0:1]
; GCN-NEXT:    v_readfirstlane_b32 s0, v0
; GCN-NEXT:    v_readfirstlane_b32 s1, v1
; GCN-NEXT:    ; return to shader part epilog
  %result = call ninf double @llvm.sqrt.f64(double %x)
  %cast = bitcast double %result to <2 x i32>
  %cast.0 = extractelement <2 x i32> %cast, i32 0
  %cast.1 = extractelement <2 x i32> %cast, i32 1
  %lane.0 = call i32 @llvm.amdgcn.readfirstlane(i32 %cast.0)
  %lane.1 = call i32 @llvm.amdgcn.readfirstlane(i32 %cast.1)
  %insert.0 = insertelement <2 x i32> poison, i32 %lane.0, i32 0
  %insert.1 = insertelement <2 x i32> %insert.0, i32 %lane.1, i32 1
  ret <2 x i32> %insert.1
}

declare double @llvm.fabs.f64(double) #0
declare double @llvm.sqrt.f64(double) #0
declare i32 @llvm.amdgcn.readfirstlane(i32) #1

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { convergent nounwind willreturn memory(none) }