Skip to content

Commit 7fc6556

Browse files
shiltianrampitec
andauthored
[AMDGPU] Mark amdgcn_tanh as canonicalized (#150059)
Co-authored-by: Mekhanoshin, Stanislav <Stanislav.Mekhanoshin@amd.com>
1 parent fbeb801 commit 7fc6556

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13633,6 +13633,7 @@ bool SITargetLowering::isCanonicalized(SelectionDAG &DAG, SDValue Op,
1363313633
case Intrinsic::amdgcn_rcp_legacy:
1363413634
case Intrinsic::amdgcn_rsq_legacy:
1363513635
case Intrinsic::amdgcn_trig_preop:
13636+
case Intrinsic::amdgcn_tanh:
1363613637
case Intrinsic::amdgcn_log:
1363713638
case Intrinsic::amdgcn_exp2:
1363813639
case Intrinsic::amdgcn_sqrt:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1250 %s -o - | FileCheck -check-prefix=GCN %s
3+
4+
define float @test_canonicalize_amdgcn_tanh_f32(float %a) {
5+
; GCN-LABEL: test_canonicalize_amdgcn_tanh_f32:
6+
; GCN: ; %bb.0:
7+
; GCN-NEXT: s_wait_loadcnt_dscnt 0x0
8+
; GCN-NEXT: s_wait_kmcnt 0x0
9+
; GCN-NEXT: v_tanh_f32_e32 v0, v0
10+
; GCN-NEXT: s_set_pc_i64 s[30:31]
11+
%tanh = call float @llvm.amdgcn.tanh.f32(float %a)
12+
%canonicalized = call float @llvm.canonicalize.f32(float %tanh)
13+
ret float %canonicalized
14+
}
15+
16+
define bfloat @test_canonicalize_amdgcn_tanh_bf16(bfloat %a) {
17+
; GCN-LABEL: test_canonicalize_amdgcn_tanh_bf16:
18+
; GCN: ; %bb.0:
19+
; GCN-NEXT: s_wait_loadcnt_dscnt 0x0
20+
; GCN-NEXT: s_wait_kmcnt 0x0
21+
; GCN-NEXT: v_tanh_bf16_e32 v0, v0
22+
; GCN-NEXT: v_nop
23+
; GCN-NEXT: s_delay_alu instid0(TRANS32_DEP_1) | instskip(NEXT) | instid1(VALU_DEP_1)
24+
; GCN-NEXT: v_lshlrev_b32_e32 v0, 16, v0
25+
; GCN-NEXT: v_max_num_f32_e32 v0, v0, v0
26+
; GCN-NEXT: s_delay_alu instid0(VALU_DEP_1)
27+
; GCN-NEXT: v_cvt_pk_bf16_f32 v0, v0, s0
28+
; GCN-NEXT: s_set_pc_i64 s[30:31]
29+
%tanh = call bfloat @llvm.amdgcn.tanh.bf16(bfloat %a)
30+
%canonicalized = call bfloat @llvm.canonicalize.bf16(bfloat %tanh)
31+
ret bfloat %canonicalized
32+
}
33+
34+
define half @test_canonicalize_amdgcn_tanh_f16(half %a) {
35+
; GCN-LABEL: test_canonicalize_amdgcn_tanh_f16:
36+
; GCN: ; %bb.0:
37+
; GCN-NEXT: s_wait_loadcnt_dscnt 0x0
38+
; GCN-NEXT: s_wait_kmcnt 0x0
39+
; GCN-NEXT: v_tanh_f16_e32 v0, v0
40+
; GCN-NEXT: s_set_pc_i64 s[30:31]
41+
%tanh = call half @llvm.amdgcn.tanh.f16(half %a)
42+
%canonicalized = call half @llvm.canonicalize.f16(half %tanh)
43+
ret half %canonicalized
44+
}

0 commit comments

Comments
 (0)