Skip to content

Commit 007e859

Browse files
abhigargrepoarsenm
andauthored
AMDGPU: Pre-commit test to verify mode change in fp constrained operations (#88858)
This test will check the mode register in case of constrained floating point operations. --------- Co-authored-by: Matt Arsenault <[email protected]>
1 parent 3f29228 commit 007e859

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 %s -o - | FileCheck -check-prefix=GCN %s
3+
4+
; The si-mode-register pass is changing the default mode for FP constrained operations.
5+
; It must ignore for strictfp functions.
6+
7+
define double @ignoreStrictfp(double noundef %a, double noundef %b) #0 {
8+
; GCN-LABEL: ignoreStrictfp:
9+
; GCN: ; %bb.0:
10+
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
11+
; GCN-NEXT: s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 2), 1
12+
; GCN-NEXT: s_nop 1
13+
; GCN-NEXT: s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 1), 0
14+
; GCN-NEXT: v_add_f64 v[0:1], v[0:1], v[2:3]
15+
; GCN-NEXT: s_setpc_b64 s[30:31]
16+
tail call void @llvm.amdgcn.s.setreg(i32 2177, i32 1)
17+
%val = tail call double @llvm.experimental.constrained.fadd.f64(double %a, double %b, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
18+
ret double %val
19+
}
20+
21+
define double @set_fpenv(double noundef %a, double noundef %b) #0 {
22+
; GCN-LABEL: set_fpenv:
23+
; GCN: ; %bb.0: ; %entry
24+
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
25+
; GCN-NEXT: s_setreg_imm32_b32 hwreg(HW_REG_MODE, 0, 23), 4
26+
; GCN-NEXT: s_setreg_imm32_b32 hwreg(HW_REG_TRAPSTS, 0, 5), 0
27+
; GCN-NEXT: s_nop 0
28+
; GCN-NEXT: s_setreg_imm32_b32 hwreg(HW_REG_MODE, 2, 1), 0
29+
; GCN-NEXT: v_add_f64 v[0:1], v[0:1], v[2:3]
30+
; GCN-NEXT: s_setpc_b64 s[30:31]
31+
entry:
32+
call void @llvm.set.fpenv.i64(i64 4)
33+
%val = tail call double @llvm.experimental.constrained.fadd.f64(double %a, double %b, metadata !"round.dynamic", metadata !"fpexcept.strict") #0
34+
ret double %val
35+
}
36+
37+
declare void @llvm.amdgcn.s.setreg(i32 immarg, i32)
38+
39+
declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
40+
41+
declare void @llvm.set.fpenv.i64(i64)
42+
43+
attributes #0 = { strictfp }

0 commit comments

Comments
 (0)