Skip to content

Commit 5d3b057

Browse files
shiltianrampitec
andauthored
[NFC][AMDGPU] Add an IR test for v_sqrt_bf16 (#149629)
This was left during the upstream. Co-authored-by: Mekhanoshin, Stanislav <[email protected]>
1 parent c9fe19a commit 5d3b057

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

llvm/test/CodeGen/AMDGPU/bf16-math.ll

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
; RUN: llc -mtriple=amdgcn -mcpu=gfx1250 < %s | FileCheck --check-prefix=GCN %s
33

44
; TODO: Add global-isel when it can support bf16
5+
define amdgpu_ps void @llvm_sqrt_bf16_v(ptr addrspace(1) %out, bfloat %src) {
6+
; GCN-LABEL: llvm_sqrt_bf16_v:
7+
; GCN: ; %bb.0:
8+
; GCN-NEXT: v_sqrt_bf16_e32 v2, v2
9+
; GCN-NEXT: global_store_b16 v[0:1], v2, off
10+
; GCN-NEXT: s_endpgm
11+
%sqrt = call bfloat @llvm.sqrt.bf16(bfloat %src)
12+
store bfloat %sqrt, ptr addrspace(1) %out, align 2
13+
ret void
14+
}
15+
16+
define amdgpu_ps void @llvm_sqrt_bf16_s(ptr addrspace(1) %out, bfloat inreg %src) {
17+
; GCN-LABEL: llvm_sqrt_bf16_s:
18+
; GCN: ; %bb.0:
19+
; GCN-NEXT: v_sqrt_bf16_e32 v2, s0
20+
; GCN-NEXT: global_store_b16 v[0:1], v2, off
21+
; GCN-NEXT: s_endpgm
22+
%sqrt = call bfloat @llvm.sqrt.bf16(bfloat %src)
23+
store bfloat %sqrt, ptr addrspace(1) %out, align 2
24+
ret void
25+
}
526

627
define amdgpu_ps void @llvm_log2_bf16_v(ptr addrspace(1) %out, bfloat %src) {
728
; GCN-LABEL: llvm_log2_bf16_v:
@@ -47,5 +68,6 @@ define amdgpu_ps void @llvm_exp2_bf16_s(ptr addrspace(1) %out, bfloat inreg %src
4768
ret void
4869
}
4970

71+
declare bfloat @llvm.sqrt.bf16(bfloat)
5072
declare bfloat @llvm.log2.bf16(bfloat)
5173
declare bfloat @llvm.exp2.bf16(bfloat)

0 commit comments

Comments
 (0)