|
3 | 3 |
|
4 | 4 | declare float @llvm.experimental.constrained.fpext.f32.f16(half, metadata) #0 |
5 | 5 | declare <2 x float> @llvm.experimental.constrained.fpext.v2f32.v2f16(<2 x half>, metadata) #0 |
| 6 | +declare half @llvm.experimental.constrained.fptrunc.f16.f32(float, metadata, metadata) #0 |
| 7 | +declare <2 x half> @llvm.experimental.constrained.fptrunc.v2f16.v2f32(<2 x float>, metadata, metadata) #0 |
| 8 | +declare float @llvm.fabs.f32(float) |
6 | 9 |
|
7 | 10 | define float @v_constrained_fpext_f16_to_f32(ptr addrspace(1) %ptr) #0 { |
8 | 11 | ; GFX7-LABEL: v_constrained_fpext_f16_to_f32: |
@@ -40,4 +43,68 @@ define <2 x float> @v_constrained_fpext_v2f16_to_v2f32(ptr addrspace(1) %ptr) #0 |
40 | 43 | ret <2 x float> %result |
41 | 44 | } |
42 | 45 |
|
| 46 | +define void @v_constrained_fptrunc_f32_to_f16_fpexcept_strict(float %arg, ptr addrspace(1) %ptr) #0 { |
| 47 | +; GFX7-LABEL: v_constrained_fptrunc_f32_to_f16_fpexcept_strict: |
| 48 | +; GFX7: ; %bb.0: |
| 49 | +; GFX7-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 50 | +; GFX7-NEXT: v_cvt_f16_f32_e32 v0, v0 |
| 51 | +; GFX7-NEXT: v_and_b32_e32 v0, 0xffff, v0 |
| 52 | +; GFX7-NEXT: v_cvt_f32_f16_e32 v0, v0 |
| 53 | +; GFX7-NEXT: s_setpc_b64 s[30:31] |
| 54 | + %result = call half @llvm.experimental.constrained.fptrunc.f16.f32(float %arg, metadata !"round.tonearest", metadata !"fpexcept.strict") |
| 55 | + ret void |
| 56 | +} |
| 57 | + |
| 58 | +define void @v_constrained_fptrunc_v2f32_to_v2f16_fpexcept_strict(<2 x float> %arg, ptr addrspace(1) %ptr) #0 { |
| 59 | +; GFX7-LABEL: v_constrained_fptrunc_v2f32_to_v2f16_fpexcept_strict: |
| 60 | +; GFX7: ; %bb.0: |
| 61 | +; GFX7-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 62 | +; GFX7-NEXT: v_cvt_f16_f32_e32 v1, v1 |
| 63 | +; GFX7-NEXT: v_cvt_f16_f32_e32 v0, v0 |
| 64 | +; GFX7-NEXT: s_mov_b32 s6, 0 |
| 65 | +; GFX7-NEXT: s_mov_b32 s7, 0xf000 |
| 66 | +; GFX7-NEXT: v_and_b32_e32 v1, 0xffff, v1 |
| 67 | +; GFX7-NEXT: v_cvt_f32_f16_e32 v1, v1 |
| 68 | +; GFX7-NEXT: v_and_b32_e32 v0, 0xffff, v0 |
| 69 | +; GFX7-NEXT: v_cvt_f32_f16_e32 v0, v0 |
| 70 | +; GFX7-NEXT: s_mov_b32 s4, s6 |
| 71 | +; GFX7-NEXT: v_cvt_f16_f32_e32 v1, v1 |
| 72 | +; GFX7-NEXT: s_mov_b32 s5, s6 |
| 73 | +; GFX7-NEXT: v_cvt_f16_f32_e32 v0, v0 |
| 74 | +; GFX7-NEXT: v_lshlrev_b32_e32 v1, 16, v1 |
| 75 | +; GFX7-NEXT: v_or_b32_e32 v0, v0, v1 |
| 76 | +; GFX7-NEXT: buffer_store_dword v0, v[2:3], s[4:7], 0 addr64 |
| 77 | +; GFX7-NEXT: s_waitcnt vmcnt(0) |
| 78 | +; GFX7-NEXT: s_setpc_b64 s[30:31] |
| 79 | + %result = call <2 x half> @llvm.experimental.constrained.fptrunc.v2f16.v2f32(<2 x float> %arg, metadata !"round.tonearest", metadata !"fpexcept.strict") |
| 80 | + store <2 x half> %result, ptr addrspace(1) %ptr |
| 81 | + ret void |
| 82 | +} |
| 83 | + |
| 84 | +define void @v_constrained_fptrunc_f32_to_f16_fpexcept_strict_fneg(float %arg, ptr addrspace(1) %ptr) #0 { |
| 85 | +; GFX7-LABEL: v_constrained_fptrunc_f32_to_f16_fpexcept_strict_fneg: |
| 86 | +; GFX7: ; %bb.0: |
| 87 | +; GFX7-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 88 | +; GFX7-NEXT: v_cvt_f16_f32_e64 v0, -v0 |
| 89 | +; GFX7-NEXT: v_and_b32_e32 v0, 0xffff, v0 |
| 90 | +; GFX7-NEXT: v_cvt_f32_f16_e32 v0, v0 |
| 91 | +; GFX7-NEXT: s_setpc_b64 s[30:31] |
| 92 | + %neg.arg = fneg float %arg |
| 93 | + %result = call half @llvm.experimental.constrained.fptrunc.f16.f32(float %neg.arg, metadata !"round.tonearest", metadata !"fpexcept.strict") |
| 94 | + ret void |
| 95 | +} |
| 96 | + |
| 97 | +define void @v_constrained_fptrunc_f32_to_f16_fpexcept_strict_fabs(float %arg, ptr addrspace(1) %ptr) #0 { |
| 98 | +; GFX7-LABEL: v_constrained_fptrunc_f32_to_f16_fpexcept_strict_fabs: |
| 99 | +; GFX7: ; %bb.0: |
| 100 | +; GFX7-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) |
| 101 | +; GFX7-NEXT: v_cvt_f16_f32_e64 v0, |v0| |
| 102 | +; GFX7-NEXT: v_and_b32_e32 v0, 0xffff, v0 |
| 103 | +; GFX7-NEXT: v_cvt_f32_f16_e32 v0, v0 |
| 104 | +; GFX7-NEXT: s_setpc_b64 s[30:31] |
| 105 | + %abs.arg = call float @llvm.fabs.f32(float %arg) |
| 106 | + %result = call half @llvm.experimental.constrained.fptrunc.f16.f32(float %abs.arg, metadata !"round.tonearest", metadata !"fpexcept.strict") |
| 107 | + ret void |
| 108 | +} |
| 109 | + |
43 | 110 | attributes #0 = { strictfp } |
0 commit comments