| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc -global-isel -mtriple=amdgcn-amd-mesa3d -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=GFX10 %s | ||
|
|
||
| define float @test_fmed3_f32_known_nnan_ieee_true(float %a) #0 { | ||
| ; GFX10-LABEL: test_fmed3_f32_known_nnan_ieee_true: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e64 v0, v0, 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %fmed = call nnan float @llvm.amdgcn.fmed3.f32(float %fmul, float 0.0, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| define half @test_fmed3_f16_known_nnan_ieee_false(half %a) #1 { | ||
| ; GFX10-LABEL: test_fmed3_f16_known_nnan_ieee_false: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f16_e64 v0, v0, 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul half %a, 2.0 | ||
| %fmed = call nnan half @llvm.amdgcn.fmed3.f16(half %fmul, half 0.0, half 1.0) | ||
| ret half %fmed | ||
| } | ||
|
|
||
| ; %fmin is known non-SNaN because fmin inputs are fcanonicalized | ||
| define float @test_fmed3_non_SNaN_input_ieee_true_dx10clamp_true(float %a) #2 { | ||
| ; GFX10-LABEL: test_fmed3_non_SNaN_input_ieee_true_dx10clamp_true: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, v0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e64 v0, 0x41200000, v0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmin = call float @llvm.minnum.f32(float %a, float 10.0) | ||
| %fmed = call float @llvm.amdgcn.fmed3.f32(float %fmin, float 0.0, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; input may be SNaN. It's safe to clamp since third operand in fmed3 is 0.0 | ||
| define float @test_fmed3_maybe_SNaN_input_zero_third_operand_ieee_true_dx10clamp_true(float %a) #2 { | ||
| ; GFX10-LABEL: test_fmed3_maybe_SNaN_input_zero_third_operand_ieee_true_dx10clamp_true: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e64 v0, v0, 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %fmed = call float @llvm.amdgcn.fmed3.f32(float %fmul, float 1.0, float 0.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; global nnan function attribute always forces clamp combine | ||
|
|
||
| define float @test_fmed3_global_nnan(float %a) #3 { | ||
| ; GFX10-LABEL: test_fmed3_global_nnan: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e64 v0, v0, 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %fmed = call float @llvm.amdgcn.fmed3.f32(float %fmul, float 0.0, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; ------------------------------------------------------------------------------ | ||
| ; Negative patterns | ||
| ; ------------------------------------------------------------------------------ | ||
|
|
||
| ; ieee=false requires known never NaN input | ||
| define float @test_fmed3_f32_maybe_NaN_ieee_false(float %a) #1 { | ||
| ; GFX10-LABEL: test_fmed3_f32_maybe_NaN_ieee_false: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 1.0, 0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %fmed = call float @llvm.amdgcn.fmed3.f32(float %fmul, float 1.0, float 0.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; ieee=true input is known non-SNaN but dx10_clamp=false | ||
| define float @test_fmed3_non_SNaN_input_ieee_true_dx10clamp_false(float %a) #4 { | ||
| ; GFX10-LABEL: test_fmed3_non_SNaN_input_ieee_true_dx10clamp_false: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, v0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 0x41200000, v0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 0, 1.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmin = call float @llvm.minnum.f32(float %a, float 10.0) | ||
| %fmed = call float @llvm.amdgcn.fmed3.f32(float %fmin, float 0.0, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; ieee=true dx10_clamp=true but input may be SNaN, clamp requires third operand in fmed3 to be 0.0 | ||
| define float @test_fmed3_maybe_SNaN_input_ieee_true_dx10clamp_true(float %a) #2 { | ||
| ; GFX10-LABEL: test_fmed3_maybe_SNaN_input_ieee_true_dx10clamp_true: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 0, 1.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %fmed = call float @llvm.amdgcn.fmed3.f32(float %fmul, float 0.0, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| declare half @llvm.amdgcn.fmed3.f16(half, half, half) | ||
| declare float @llvm.amdgcn.fmed3.f32(float, float, float) | ||
| declare float @llvm.minnum.f32(float, float) | ||
|
|
||
| attributes #0 = {"amdgpu-ieee"="true"} | ||
| attributes #1 = {"amdgpu-ieee"="false"} | ||
| attributes #2 = {"amdgpu-ieee"="true" "amdgpu-dx10-clamp"="true"} | ||
| attributes #3 = {"no-nans-fp-math"="true"} | ||
| attributes #4 = {"amdgpu-ieee"="true" "amdgpu-dx10-clamp"="false"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,262 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc -global-isel -mtriple=amdgcn-amd-mesa3d -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=GFX10 %s | ||
|
|
||
| define float @test_min_max_ValK0_K1_f32(float %a) #0 { | ||
| ; GFX10-LABEL: test_min_max_ValK0_K1_f32: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e64 v0, v0, 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %maxnum = call nnan float @llvm.maxnum.f32(float %fmul, float 0.0) | ||
| %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| define double @test_min_max_K0Val_K1_f64(double %a) #1 { | ||
| ; GFX10-LABEL: test_min_max_K0Val_K1_f64: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f64 v[0:1], v[0:1], 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul double %a, 2.0 | ||
| %maxnum = call nnan double @llvm.maxnum.f64(double 0.0, double %fmul) | ||
| %fmed = call nnan double @llvm.minnum.f64(double %maxnum, double 1.0) | ||
| ret double %fmed | ||
| } | ||
|
|
||
| ; min-max patterns for ieee=true, dx10_clamp=true don't have to check for NaNs | ||
| define half @test_min_K1max_ValK0_f16(half %a) #2 { | ||
| ; GFX10-LABEL: test_min_K1max_ValK0_f16: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f16_e64 v0, v0, 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul half %a, 2.0 | ||
| %maxnum = call half @llvm.maxnum.f16(half %fmul, half 0.0) | ||
| %fmed = call half @llvm.minnum.f16(half 1.0, half %maxnum) | ||
| ret half %fmed | ||
| } | ||
|
|
||
| define <2 x half> @test_min_K1max_K0Val_f16(<2 x half> %a) #1 { | ||
| ; GFX10-LABEL: test_min_K1max_K0Val_f16: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_pk_mul_f16 v0, v0, 2.0 op_sel_hi:[1,0] clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul <2 x half> %a, <half 2.0, half 2.0> | ||
| %maxnum = call nnan <2 x half> @llvm.maxnum.v2f16(<2 x half> <half 0.0, half 0.0>, <2 x half> %fmul) | ||
| %fmed = call nnan <2 x half> @llvm.minnum.v2f16(<2 x half> <half 1.0, half 1.0>, <2 x half> %maxnum) | ||
| ret <2 x half> %fmed | ||
| } | ||
|
|
||
| define <2 x half> @test_min_max_splat_padded_with_undef(<2 x half> %a) #2 { | ||
| ; GFX10-LABEL: test_min_max_splat_padded_with_undef: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_pk_mul_f16 v0, v0, 2.0 op_sel_hi:[1,0] clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul <2 x half> %a, <half 2.0, half 2.0> | ||
| %maxnum = call <2 x half> @llvm.maxnum.v2f16(<2 x half> <half 0.0, half undef>, <2 x half> %fmul) | ||
| %fmed = call <2 x half> @llvm.minnum.v2f16(<2 x half> <half 1.0, half undef>, <2 x half> %maxnum) | ||
| ret <2 x half> %fmed | ||
| } | ||
|
|
||
| ; max-mix patterns work only for known non-NaN inputs | ||
|
|
||
| define float @test_max_min_ValK1_K0_f32(float %a) #0 { | ||
| ; GFX10-LABEL: test_max_min_ValK1_K0_f32: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e64 v0, v0, 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %minnum = call nnan float @llvm.minnum.f32(float %fmul, float 1.0) | ||
| %fmed = call nnan float @llvm.maxnum.f32(float %minnum, float 0.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| define double @test_max_min_K1Val_K0_f64(double %a) #1 { | ||
| ; GFX10-LABEL: test_max_min_K1Val_K0_f64: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f64 v[0:1], v[0:1], 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul double %a, 2.0 | ||
| %minnum = call nnan double @llvm.minnum.f64(double 1.0, double %fmul) | ||
| %fmed = call nnan double @llvm.maxnum.f64(double %minnum, double 0.0) | ||
| ret double %fmed | ||
| } | ||
|
|
||
| define half @test_max_K0min_ValK1_f16(half %a) #0 { | ||
| ; GFX10-LABEL: test_max_K0min_ValK1_f16: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f16_e64 v0, v0, 2.0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul half %a, 2.0 | ||
| %minnum = call nnan half @llvm.minnum.f16(half %fmul, half 1.0) | ||
| %fmed = call nnan half @llvm.maxnum.f16(half 0.0, half %minnum) | ||
| ret half %fmed | ||
| } | ||
|
|
||
| ; treat undef as value that will result in a constant splat | ||
| define <2 x half> @test_max_K0min_K1Val_v2f16(<2 x half> %a) #1 { | ||
| ; GFX10-LABEL: test_max_K0min_K1Val_v2f16: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_pk_mul_f16 v0, v0, 2.0 op_sel_hi:[1,0] clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul <2 x half> %a, <half 2.0, half 2.0> | ||
| %minnum = call nnan <2 x half> @llvm.minnum.v2f16(<2 x half> <half 1.0, half undef>, <2 x half> %fmul) | ||
| %fmed = call nnan <2 x half> @llvm.maxnum.v2f16(<2 x half> <half undef, half 0.0>, <2 x half> %minnum) | ||
| ret <2 x half> %fmed | ||
| } | ||
|
|
||
| ; global nnan function attribute always forces clamp combine | ||
|
|
||
| define float @test_min_max_global_nnan(float %a) #3 { | ||
| ; GFX10-LABEL: test_min_max_global_nnan: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f32_e64 v0, v0, v0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call float @llvm.maxnum.f32(float %a, float 0.0) | ||
| %fmed = call float @llvm.minnum.f32(float %maxnum, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| define float @test_max_min_global_nnan(float %a) #3 { | ||
| ; GFX10-LABEL: test_max_min_global_nnan: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f32_e64 v0, v0, v0 clamp | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call float @llvm.minnum.f32(float %a, float 1.0) | ||
| %fmed = call float @llvm.maxnum.f32(float %minnum, float 0.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; ------------------------------------------------------------------------------ | ||
| ; Negative patterns | ||
| ; ------------------------------------------------------------------------------ | ||
|
|
||
| ; min(max(Val, 1.0), 0.0), should be min(max(Val, 0.0), 1.0) | ||
| define float @test_min_max_K0_gt_K1(float %a) #0 { | ||
| ; GFX10-LABEL: test_min_max_K0_gt_K1: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 1.0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call nnan float @llvm.maxnum.f32(float %a, float 1.0) | ||
| %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 0.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; max(min(Val, 0.0), 1.0), should be max(min(Val, 1.0), 0.0) | ||
| define float @test_max_min_K0_gt_K1(float %a) #0 { | ||
| ; GFX10-LABEL: test_max_min_K0_gt_K1: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 0, v0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 1.0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call nnan float @llvm.minnum.f32(float %a, float 0.0) | ||
| %fmed = call nnan float @llvm.maxnum.f32(float %minnum, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; Input that can be NaN | ||
|
|
||
| ; min-max patterns for ieee=false require known non-NaN input | ||
| define float @test_min_max_maybe_NaN_input_ieee_false(float %a) #1 { | ||
| ; GFX10-LABEL: test_min_max_maybe_NaN_input_ieee_false: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 1.0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %maxnum = call float @llvm.maxnum.f32(float %fmul, float 0.0) | ||
| %fmed = call float @llvm.minnum.f32(float %maxnum, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; clamp fails here since input can be NaN and dx10_clamp=false; fmed3 succeds | ||
| define float @test_min_max_maybe_NaN_input_ieee_true_dx10clamp_false(float %a) #4 { | ||
| ; GFX10-LABEL: test_min_max_maybe_NaN_input_ieee_true_dx10clamp_false: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, v0, v0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 0, 1.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %maxnum = call float @llvm.maxnum.f32(float %fmul, float 0.0) | ||
| %fmed = call float @llvm.minnum.f32(float %maxnum, float 1.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; max-min patterns always require known non-NaN input | ||
|
|
||
| define float @test_max_min_maybe_NaN_input_ieee_true(float %a) #0 { | ||
| ; GFX10-LABEL: test_max_min_maybe_NaN_input_ieee_true: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, v0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 1.0, v0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %minnum = call float @llvm.minnum.f32(float %fmul, float 1.0) | ||
| %fmed = call float @llvm.maxnum.f32(float %minnum, float 0.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| define float @test_max_min_maybe_NaN_input_ieee_false(float %a) #1 { | ||
| ; GFX10-LABEL: test_max_min_maybe_NaN_input_ieee_false: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_mul_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 1.0, v0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %fmul = fmul float %a, 2.0 | ||
| %minnum = call float @llvm.minnum.f32(float %fmul, float 1.0) | ||
| %fmed = call float @llvm.maxnum.f32(float %minnum, float 0.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| declare half @llvm.minnum.f16(half, half) | ||
| declare half @llvm.maxnum.f16(half, half) | ||
| declare float @llvm.minnum.f32(float, float) | ||
| declare float @llvm.maxnum.f32(float, float) | ||
| declare double @llvm.minnum.f64(double, double) | ||
| declare double @llvm.maxnum.f64(double, double) | ||
| declare <2 x half> @llvm.minnum.v2f16(<2 x half>, <2 x half>) | ||
| declare <2 x half> @llvm.maxnum.v2f16(<2 x half>, <2 x half>) | ||
| attributes #0 = {"amdgpu-ieee"="true"} | ||
| attributes #1 = {"amdgpu-ieee"="false"} | ||
| attributes #2 = {"amdgpu-ieee"="true" "amdgpu-dx10-clamp"="true"} | ||
| attributes #3 = {"no-nans-fp-math"="true"} | ||
| attributes #4 = {"amdgpu-ieee"="true" "amdgpu-dx10-clamp"="false"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,260 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc -global-isel -mtriple=amdgcn-amd-mesa3d -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=GFX10 %s | ||
|
|
||
| define float @test_min_max_ValK0_K1_f32(float %a) #0 { | ||
| ; GFX10-LABEL: test_min_max_ValK0_K1_f32: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call nnan float @llvm.maxnum.f32(float %a, float 2.0) | ||
| %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 4.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| define float @test_min_max_K0Val_K1_f32(float %a) #1 { | ||
| ; GFX10-LABEL: test_min_max_K0Val_K1_f32: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call nnan float @llvm.maxnum.f32(float 2.0, float %a) | ||
| %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 4.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; min-max patterns for ieee=true do not have to check for NaNs | ||
| ; 'v_max_f16_e32 v0, v0, v0' is from fcanonicalize of the input to fmin/fmax with ieee=true | ||
| define half @test_min_K1max_ValK0_f16(half %a) #0 { | ||
| ; GFX10-LABEL: test_min_K1max_ValK0_f16: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f16_e32 v0, v0, v0 | ||
| ; GFX10-NEXT: v_med3_f16 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call half @llvm.maxnum.f16(half %a, half 2.0) | ||
| %fmed = call half @llvm.minnum.f16(half 4.0, half %maxnum) | ||
| ret half %fmed | ||
| } | ||
|
|
||
| define half @test_min_K1max_K0Val_f16(half %a) #1 { | ||
| ; GFX10-LABEL: test_min_K1max_K0Val_f16: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_med3_f16 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call nnan half @llvm.maxnum.f16(half 2.0, half %a) | ||
| %fmed = call nnan half @llvm.minnum.f16(half 4.0, half %maxnum) | ||
| ret half %fmed | ||
| } | ||
|
|
||
| ; max-mix patterns work only for non-NaN inputs | ||
| define float @test_max_min_ValK1_K0_f32(float %a) #0 { | ||
| ; GFX10-LABEL: test_max_min_ValK1_K0_f32: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call nnan float @llvm.minnum.f32(float %a, float 4.0) | ||
| %fmed = call nnan float @llvm.maxnum.f32(float %minnum, float 2.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| define float @test_max_min_K1Val_K0_f32(float %a) #1 { | ||
| ; GFX10-LABEL: test_max_min_K1Val_K0_f32: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call nnan float @llvm.minnum.f32(float 4.0, float %a) | ||
| %fmed = call nnan float @llvm.maxnum.f32(float %minnum, float 2.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| define half @test_max_K0min_ValK1_f16(half %a) #0 { | ||
| ; GFX10-LABEL: test_max_K0min_ValK1_f16: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_med3_f16 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call nnan half @llvm.minnum.f16(half %a, half 4.0) | ||
| %fmed = call nnan half @llvm.maxnum.f16(half 2.0, half %minnum) | ||
| ret half %fmed | ||
| } | ||
|
|
||
| define half @test_max_K0min_K1Val_f16(half %a) #1 { | ||
| ; GFX10-LABEL: test_max_K0min_K1Val_f16: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_med3_f16 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call nnan half @llvm.minnum.f16(half 4.0, half %a) | ||
| %fmed = call nnan half @llvm.maxnum.f16(half 2.0, half %minnum) | ||
| ret half %fmed | ||
| } | ||
|
|
||
| ; global nnan function attribute always forces fmed3 combine | ||
|
|
||
| define float @test_min_max_global_nnan(float %a) #2 { | ||
| ; GFX10-LABEL: test_min_max_global_nnan: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call float @llvm.maxnum.f32(float %a, float 2.0) | ||
| %fmed = call float @llvm.minnum.f32(float %maxnum, float 4.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| define float @test_max_min_global_nnan(float %a) #2 { | ||
| ; GFX10-LABEL: test_max_min_global_nnan: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_med3_f32 v0, v0, 2.0, 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call float @llvm.minnum.f32(float %a, float 4.0) | ||
| %fmed = call float @llvm.maxnum.f32(float %minnum, float 2.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; ------------------------------------------------------------------------------ | ||
| ; Negative patterns | ||
| ; ------------------------------------------------------------------------------ | ||
|
|
||
| ; min(max(Val, K0), K1) K0 > K1, should be K0<=K1 | ||
| define float @test_min_max_K0_gt_K1(float %a) #0 { | ||
| ; GFX10-LABEL: test_min_max_K0_gt_K1: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 4.0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call nnan float @llvm.maxnum.f32(float %a, float 4.0) | ||
| %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 2.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; max(min(Val, K1), K0) K0 > K1, should be K0<=K1 | ||
| define float @test_max_min_K0_gt_K1(float %a) #0 { | ||
| ; GFX10-LABEL: test_max_min_K0_gt_K1: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 4.0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call nnan float @llvm.minnum.f32(float %a, float 2.0) | ||
| %fmed = call nnan float @llvm.maxnum.f32(float %minnum, float 4.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; non-inline constant | ||
| define float @test_min_max_non_inline_const(float %a) #0 { | ||
| ; GFX10-LABEL: test_min_max_non_inline_const: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 0x41000000, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call nnan float @llvm.maxnum.f32(float %a, float 2.0) | ||
| %fmed = call nnan float @llvm.minnum.f32(float %maxnum, float 8.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; there is no fmed3 for f64 or v2f16 types | ||
|
|
||
| define double @test_min_max_f64(double %a) #0 { | ||
| ; GFX10-LABEL: test_min_max_f64: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f64 v[0:1], v[0:1], 2.0 | ||
| ; GFX10-NEXT: v_min_f64 v[0:1], v[0:1], 4.0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call nnan double @llvm.maxnum.f64(double %a, double 2.0) | ||
| %fmed = call nnan double @llvm.minnum.f64(double %maxnum, double 4.0) | ||
| ret double %fmed | ||
| } | ||
|
|
||
| define <2 x half> @test_min_max_v2f16(<2 x half> %a) #0 { | ||
| ; GFX10-LABEL: test_min_max_v2f16: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_pk_max_f16 v0, v0, 2.0 op_sel_hi:[1,0] | ||
| ; GFX10-NEXT: v_pk_min_f16 v0, v0, 4.0 op_sel_hi:[1,0] | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call nnan <2 x half> @llvm.maxnum.v2f16(<2 x half> %a, <2 x half> <half 2.0, half 2.0>) | ||
| %fmed = call nnan <2 x half> @llvm.minnum.v2f16(<2 x half> %maxnum, <2 x half> <half 4.0, half 4.0>) | ||
| ret <2 x half> %fmed | ||
| } | ||
|
|
||
| ; input that can be NaN | ||
|
|
||
| ; min-max patterns for ieee=false require known non-NaN input | ||
| define float @test_min_max_maybe_NaN_input_ieee_false(float %a) #1 { | ||
| ; GFX10-LABEL: test_min_max_maybe_NaN_input_ieee_false: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 4.0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %maxnum = call float @llvm.maxnum.f32(float %a, float 2.0) | ||
| %fmed = call float @llvm.minnum.f32(float %maxnum, float 4.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; max-min patterns always require known non-NaN input | ||
|
|
||
| define float @test_max_min_maybe_NaN_input_ieee_false(float %a) #1 { | ||
| ; GFX10-LABEL: test_max_min_maybe_NaN_input_ieee_false: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 4.0, v0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call float @llvm.minnum.f32(float %a, float 4.0) | ||
| %fmed = call float @llvm.maxnum.f32(float %minnum, float 2.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| ; 'v_max_f32_e32 v0, v0, v0' is from fcanonicalize of the input to fmin/fmax with ieee=true | ||
| define float @test_max_min_maybe_NaN_input_ieee_true(float %a) #0 { | ||
| ; GFX10-LABEL: test_max_min_maybe_NaN_input_ieee_true: | ||
| ; GFX10: ; %bb.0: | ||
| ; GFX10-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) | ||
| ; GFX10-NEXT: s_waitcnt_vscnt null, 0x0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, v0, v0 | ||
| ; GFX10-NEXT: v_min_f32_e32 v0, 4.0, v0 | ||
| ; GFX10-NEXT: v_max_f32_e32 v0, 2.0, v0 | ||
| ; GFX10-NEXT: s_setpc_b64 s[30:31] | ||
| %minnum = call float @llvm.minnum.f32(float %a, float 4.0) | ||
| %fmed = call float @llvm.maxnum.f32(float %minnum, float 2.0) | ||
| ret float %fmed | ||
| } | ||
|
|
||
| declare half @llvm.minnum.f16(half, half) | ||
| declare half @llvm.maxnum.f16(half, half) | ||
| declare float @llvm.minnum.f32(float, float) | ||
| declare float @llvm.maxnum.f32(float, float) | ||
| declare double @llvm.minnum.f64(double, double) | ||
| declare double @llvm.maxnum.f64(double, double) | ||
| declare <2 x half> @llvm.minnum.v2f16(<2 x half>, <2 x half>) | ||
| declare <2 x half> @llvm.maxnum.v2f16(<2 x half>, <2 x half>) | ||
| attributes #0 = {"amdgpu-ieee"="true"} | ||
| attributes #1 = {"amdgpu-ieee"="false"} | ||
| attributes #2 = {"no-nans-fp-math"="true"} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,261 @@ | ||
| # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py | ||
| # RUN: llc -mtriple=amdgcn-amd-mesa3d -mcpu=gfx1010 -run-pass=amdgpu-regbank-combiner -verify-machineinstrs %s -o - | FileCheck %s | ||
| --- | ||
| name: test_fmed3_f32_known_nnan_ieee_true | ||
| legalized: true | ||
| regBankSelected: true | ||
| tracksRegLiveness: true | ||
| machineFunctionInfo: | ||
| mode: | ||
| ieee: true | ||
| dx10-clamp: true | ||
| body: | | ||
| bb.1 : | ||
| liveins: $vgpr0 | ||
| ; CHECK-LABEL: name: test_fmed3_f32_known_nnan_ieee_true | ||
| ; CHECK: liveins: $vgpr0 | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0 | ||
| ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 2.000000e+00 | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32) | ||
| ; CHECK-NEXT: [[FMUL:%[0-9]+]]:vgpr(s32) = G_FMUL [[COPY]], [[COPY1]] | ||
| ; CHECK-NEXT: [[AMDGPU_CLAMP:%[0-9]+]]:vgpr(s32) = nnan G_AMDGPU_CLAMP [[FMUL]] | ||
| ; CHECK-NEXT: $vgpr0 = COPY [[AMDGPU_CLAMP]](s32) | ||
| %0:vgpr(s32) = COPY $vgpr0 | ||
| %2:sgpr(s32) = G_FCONSTANT float 2.000000e+00 | ||
| %8:vgpr(s32) = COPY %2(s32) | ||
| %3:vgpr(s32) = G_FMUL %0, %8 | ||
| %6:sgpr(s32) = G_FCONSTANT float 1.000000e+00 | ||
| %5:sgpr(s32) = G_FCONSTANT float 0.000000e+00 | ||
| %9:vgpr(s32) = COPY %5(s32) | ||
| %10:vgpr(s32) = COPY %6(s32) | ||
| %4:vgpr(s32) = nnan G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), %3(s32), %9(s32), %10(s32) | ||
| $vgpr0 = COPY %4(s32) | ||
| ... | ||
|
|
||
| --- | ||
| name: test_fmed3_f16_known_nnan_ieee_false | ||
| legalized: true | ||
| regBankSelected: true | ||
| tracksRegLiveness: true | ||
| machineFunctionInfo: | ||
| mode: | ||
| ieee: false | ||
| dx10-clamp: true | ||
| body: | | ||
| bb.1 : | ||
| liveins: $vgpr0 | ||
| ; CHECK-LABEL: name: test_fmed3_f16_known_nnan_ieee_false | ||
| ; CHECK: liveins: $vgpr0 | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0 | ||
| ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:vgpr(s16) = G_TRUNC [[COPY]](s32) | ||
| ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s16) = G_FCONSTANT half 0xH4000 | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s16) = COPY [[C]](s16) | ||
| ; CHECK-NEXT: [[FMUL:%[0-9]+]]:vgpr(s16) = G_FMUL [[TRUNC]], [[COPY1]] | ||
| ; CHECK-NEXT: [[AMDGPU_CLAMP:%[0-9]+]]:vgpr(s16) = nnan G_AMDGPU_CLAMP [[FMUL]] | ||
| ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:vgpr(s32) = G_ANYEXT [[AMDGPU_CLAMP]](s16) | ||
| ; CHECK-NEXT: $vgpr0 = COPY [[ANYEXT]](s32) | ||
| %2:vgpr(s32) = COPY $vgpr0 | ||
| %0:vgpr(s16) = G_TRUNC %2(s32) | ||
| %3:sgpr(s16) = G_FCONSTANT half 0xH4000 | ||
| %10:vgpr(s16) = COPY %3(s16) | ||
| %4:vgpr(s16) = G_FMUL %0, %10 | ||
| %7:sgpr(s16) = G_FCONSTANT half 0xH3C00 | ||
| %6:sgpr(s16) = G_FCONSTANT half 0xH0000 | ||
| %11:vgpr(s16) = COPY %6(s16) | ||
| %12:vgpr(s16) = COPY %7(s16) | ||
| %5:vgpr(s16) = nnan G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), %4(s16), %11(s16), %12(s16) | ||
| %9:vgpr(s32) = G_ANYEXT %5(s16) | ||
| $vgpr0 = COPY %9(s32) | ||
| ... | ||
|
|
||
| --- | ||
| name: test_fmed3_non_SNaN_input_ieee_true_dx10clamp_true | ||
| legalized: true | ||
| regBankSelected: true | ||
| tracksRegLiveness: true | ||
| machineFunctionInfo: | ||
| mode: | ||
| ieee: true | ||
| dx10-clamp: true | ||
| body: | | ||
| bb.1 : | ||
| liveins: $vgpr0 | ||
| ; CHECK-LABEL: name: test_fmed3_non_SNaN_input_ieee_true_dx10clamp_true | ||
| ; CHECK: liveins: $vgpr0 | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0 | ||
| ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 1.000000e+01 | ||
| ; CHECK-NEXT: [[FCANONICALIZE:%[0-9]+]]:vgpr(s32) = G_FCANONICALIZE [[COPY]] | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32) | ||
| ; CHECK-NEXT: [[FMINNUM_IEEE:%[0-9]+]]:vgpr(s32) = G_FMINNUM_IEEE [[FCANONICALIZE]], [[COPY1]] | ||
| ; CHECK-NEXT: [[AMDGPU_CLAMP:%[0-9]+]]:vgpr(s32) = G_AMDGPU_CLAMP [[FMINNUM_IEEE]] | ||
| ; CHECK-NEXT: $vgpr0 = COPY [[AMDGPU_CLAMP]](s32) | ||
| %0:vgpr(s32) = COPY $vgpr0 | ||
| %2:sgpr(s32) = G_FCONSTANT float 1.000000e+01 | ||
| %8:vgpr(s32) = G_FCANONICALIZE %0 | ||
| %9:vgpr(s32) = COPY %2(s32) | ||
| %3:vgpr(s32) = G_FMINNUM_IEEE %8, %9 | ||
| %6:sgpr(s32) = G_FCONSTANT float 1.000000e+00 | ||
| %5:sgpr(s32) = G_FCONSTANT float 0.000000e+00 | ||
| %10:vgpr(s32) = COPY %5(s32) | ||
| %11:vgpr(s32) = COPY %6(s32) | ||
| %4:vgpr(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), %3(s32), %10(s32), %11(s32) | ||
| $vgpr0 = COPY %4(s32) | ||
| ... | ||
|
|
||
| --- | ||
| name: test_fmed3_maybe_SNaN_input_zero_third_operand_ieee_true_dx10clamp_true | ||
| legalized: true | ||
| regBankSelected: true | ||
| tracksRegLiveness: true | ||
| machineFunctionInfo: | ||
| mode: | ||
| ieee: true | ||
| dx10-clamp: true | ||
| body: | | ||
| bb.1 : | ||
| liveins: $vgpr0 | ||
| ; CHECK-LABEL: name: test_fmed3_maybe_SNaN_input_zero_third_operand_ieee_true_dx10clamp_true | ||
| ; CHECK: liveins: $vgpr0 | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0 | ||
| ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 2.000000e+00 | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32) | ||
| ; CHECK-NEXT: [[FMUL:%[0-9]+]]:vgpr(s32) = G_FMUL [[COPY]], [[COPY1]] | ||
| ; CHECK-NEXT: [[AMDGPU_CLAMP:%[0-9]+]]:vgpr(s32) = G_AMDGPU_CLAMP [[FMUL]] | ||
| ; CHECK-NEXT: $vgpr0 = COPY [[AMDGPU_CLAMP]](s32) | ||
| %0:vgpr(s32) = COPY $vgpr0 | ||
| %2:sgpr(s32) = G_FCONSTANT float 2.000000e+00 | ||
| %8:vgpr(s32) = COPY %2(s32) | ||
| %3:vgpr(s32) = G_FMUL %0, %8 | ||
| %6:sgpr(s32) = G_FCONSTANT float 0.000000e+00 | ||
| %5:sgpr(s32) = G_FCONSTANT float 1.000000e+00 | ||
| %9:vgpr(s32) = COPY %5(s32) | ||
| %10:vgpr(s32) = COPY %6(s32) | ||
| %4:vgpr(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), %3(s32), %9(s32), %10(s32) | ||
| $vgpr0 = COPY %4(s32) | ||
| ... | ||
|
|
||
| # FixMe: add tests with attributes #3 = {"no-nans-fp-math"="true"} | ||
|
|
||
| --- | ||
| name: test_fmed3_f32_maybe_NaN_ieee_false | ||
| legalized: true | ||
| regBankSelected: true | ||
| tracksRegLiveness: true | ||
| machineFunctionInfo: | ||
| mode: | ||
| ieee: false | ||
| dx10-clamp: true | ||
| body: | | ||
| bb.1 : | ||
| liveins: $vgpr0 | ||
| ; CHECK-LABEL: name: test_fmed3_f32_maybe_NaN_ieee_false | ||
| ; CHECK: liveins: $vgpr0 | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0 | ||
| ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 2.000000e+00 | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32) | ||
| ; CHECK-NEXT: [[FMUL:%[0-9]+]]:vgpr(s32) = G_FMUL [[COPY]], [[COPY1]] | ||
| ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 0.000000e+00 | ||
| ; CHECK-NEXT: [[C2:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 1.000000e+00 | ||
| ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[C2]](s32) | ||
| ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[C1]](s32) | ||
| ; CHECK-NEXT: [[INT:%[0-9]+]]:vgpr(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), [[FMUL]](s32), [[COPY2]](s32), [[COPY3]](s32) | ||
| ; CHECK-NEXT: $vgpr0 = COPY [[INT]](s32) | ||
| %0:vgpr(s32) = COPY $vgpr0 | ||
| %2:sgpr(s32) = G_FCONSTANT float 2.000000e+00 | ||
| %8:vgpr(s32) = COPY %2(s32) | ||
| %3:vgpr(s32) = G_FMUL %0, %8 | ||
| %6:sgpr(s32) = G_FCONSTANT float 0.000000e+00 | ||
| %5:sgpr(s32) = G_FCONSTANT float 1.000000e+00 | ||
| %9:vgpr(s32) = COPY %5(s32) | ||
| %10:vgpr(s32) = COPY %6(s32) | ||
| %4:vgpr(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), %3(s32), %9(s32), %10(s32) | ||
| $vgpr0 = COPY %4(s32) | ||
| ... | ||
|
|
||
| --- | ||
| name: test_fmed3_non_SNaN_input_ieee_true_dx10clamp_false | ||
| legalized: true | ||
| regBankSelected: true | ||
| tracksRegLiveness: true | ||
| machineFunctionInfo: | ||
| mode: | ||
| ieee: true | ||
| dx10-clamp: false | ||
| body: | | ||
| bb.1 : | ||
| liveins: $vgpr0 | ||
| ; CHECK-LABEL: name: test_fmed3_non_SNaN_input_ieee_true_dx10clamp_false | ||
| ; CHECK: liveins: $vgpr0 | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0 | ||
| ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 1.000000e+01 | ||
| ; CHECK-NEXT: [[FCANONICALIZE:%[0-9]+]]:vgpr(s32) = G_FCANONICALIZE [[COPY]] | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32) | ||
| ; CHECK-NEXT: [[FMINNUM_IEEE:%[0-9]+]]:vgpr(s32) = G_FMINNUM_IEEE [[FCANONICALIZE]], [[COPY1]] | ||
| ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 1.000000e+00 | ||
| ; CHECK-NEXT: [[C2:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 0.000000e+00 | ||
| ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[C2]](s32) | ||
| ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[C1]](s32) | ||
| ; CHECK-NEXT: [[INT:%[0-9]+]]:vgpr(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), [[FMINNUM_IEEE]](s32), [[COPY2]](s32), [[COPY3]](s32) | ||
| ; CHECK-NEXT: $vgpr0 = COPY [[INT]](s32) | ||
| %0:vgpr(s32) = COPY $vgpr0 | ||
| %2:sgpr(s32) = G_FCONSTANT float 1.000000e+01 | ||
| %8:vgpr(s32) = G_FCANONICALIZE %0 | ||
| %9:vgpr(s32) = COPY %2(s32) | ||
| %3:vgpr(s32) = G_FMINNUM_IEEE %8, %9 | ||
| %6:sgpr(s32) = G_FCONSTANT float 1.000000e+00 | ||
| %5:sgpr(s32) = G_FCONSTANT float 0.000000e+00 | ||
| %10:vgpr(s32) = COPY %5(s32) | ||
| %11:vgpr(s32) = COPY %6(s32) | ||
| %4:vgpr(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), %3(s32), %10(s32), %11(s32) | ||
| $vgpr0 = COPY %4(s32) | ||
| ... | ||
|
|
||
| --- | ||
| name: test_fmed3_maybe_SNaN_input_ieee_true_dx10clamp_true | ||
| legalized: true | ||
| regBankSelected: true | ||
| tracksRegLiveness: true | ||
| machineFunctionInfo: | ||
| mode: | ||
| ieee: true | ||
| dx10-clamp: true | ||
| body: | | ||
| bb.1 : | ||
| liveins: $vgpr0 | ||
| ; CHECK-LABEL: name: test_fmed3_maybe_SNaN_input_ieee_true_dx10clamp_true | ||
| ; CHECK: liveins: $vgpr0 | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: [[COPY:%[0-9]+]]:vgpr(s32) = COPY $vgpr0 | ||
| ; CHECK-NEXT: [[C:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 2.000000e+00 | ||
| ; CHECK-NEXT: [[COPY1:%[0-9]+]]:vgpr(s32) = COPY [[C]](s32) | ||
| ; CHECK-NEXT: [[FMUL:%[0-9]+]]:vgpr(s32) = G_FMUL [[COPY]], [[COPY1]] | ||
| ; CHECK-NEXT: [[C1:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 1.000000e+00 | ||
| ; CHECK-NEXT: [[C2:%[0-9]+]]:sgpr(s32) = G_FCONSTANT float 0.000000e+00 | ||
| ; CHECK-NEXT: [[COPY2:%[0-9]+]]:vgpr(s32) = COPY [[C2]](s32) | ||
| ; CHECK-NEXT: [[COPY3:%[0-9]+]]:vgpr(s32) = COPY [[C1]](s32) | ||
| ; CHECK-NEXT: [[INT:%[0-9]+]]:vgpr(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), [[FMUL]](s32), [[COPY2]](s32), [[COPY3]](s32) | ||
| ; CHECK-NEXT: $vgpr0 = COPY [[INT]](s32) | ||
| %0:vgpr(s32) = COPY $vgpr0 | ||
| %2:sgpr(s32) = G_FCONSTANT float 2.000000e+00 | ||
| %8:vgpr(s32) = COPY %2(s32) | ||
| %3:vgpr(s32) = G_FMUL %0, %8 | ||
| %6:sgpr(s32) = G_FCONSTANT float 1.000000e+00 | ||
| %5:sgpr(s32) = G_FCONSTANT float 0.000000e+00 | ||
| %9:vgpr(s32) = COPY %5(s32) | ||
| %10:vgpr(s32) = COPY %6(s32) | ||
| %4:vgpr(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.fmed3), %3(s32), %9(s32), %10(s32) | ||
| $vgpr0 = COPY %4(s32) | ||
| ... |