[PATCH 1/1] R600: Fix FROUND
Tom Stellard
tom at stellard.net
Fri Sep 5 06:49:27 PDT 2014
On Thu, Sep 04, 2014 at 04:52:47PM -0400, Jan Vesely wrote:
> round halfway cases away from zero
>
LGTM.
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
>
> Fixes 'round' piglit
>
> lib/Target/R600/EvergreenInstructions.td | 2 +-
> lib/Target/R600/R600Instructions.td | 9 ++++++---
> test/CodeGen/R600/llvm.round.ll | 14 ++++++++------
> 3 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/lib/Target/R600/EvergreenInstructions.td b/lib/Target/R600/EvergreenInstructions.td
> index a83567a..ea3f550 100644
> --- a/lib/Target/R600/EvergreenInstructions.td
> +++ b/lib/Target/R600/EvergreenInstructions.td
> @@ -537,7 +537,7 @@ def : Pat<(fp_to_uint f32:$src0), (FLT_TO_UINT_eg (TRUNC $src0))>;
> // SHA-256 Patterns
> def : SHA256MaPattern <BFI_INT_eg, XOR_INT>;
>
> -def : FROUNDPat <CNDGE_eg>;
> +def : FROUNDPat <CNDGE_eg, CNDGT_eg>;
>
> def EG_ExportSwz : ExportSwzInst {
> let Word1{19-16} = 0; // BURST_COUNT
> diff --git a/lib/Target/R600/R600Instructions.td b/lib/Target/R600/R600Instructions.td
> index 671f923..a883c83 100644
> --- a/lib/Target/R600/R600Instructions.td
> +++ b/lib/Target/R600/R600Instructions.td
> @@ -1141,9 +1141,12 @@ class TGSI_LIT_Z_Common <InstR600 mul_lit, InstR600 log_clamped, InstR600 exp_ie
> >;
>
> // FROUND pattern
> -class FROUNDPat<Instruction CNDGE> : Pat <
> +class FROUNDPat<Instruction CNDGE, Instruction CNDGT> : Pat <
> (AMDGPUround f32:$x),
> - (CNDGE (ADD (FNEG_R600 (f32 HALF)), (FRACT $x)), (CEIL $x), (FLOOR $x))
> + (CNDGE $x,
> + (CNDGE (ADD (FNEG_R600 (f32 HALF)), (FRACT $x)), (CEIL $x), (FLOOR $x)),
> + (CNDGT (ADD (FNEG_R600 (f32 HALF)), (FRACT $x)), (CEIL $x), (FLOOR $x))
> + )
> >;
>
>
> @@ -1190,7 +1193,7 @@ let Predicates = [isR600] in {
> def : Pat<(fsqrt f32:$src), (MUL $src, (RECIPSQRT_CLAMPED_r600 $src))>;
> defm : RsqPat<RECIPSQRT_IEEE_r600, f32>;
>
> - def : FROUNDPat <CNDGE_r600>;
> + def : FROUNDPat <CNDGE_r600, CNDGT_r600>;
>
> def R600_ExportSwz : ExportSwzInst {
> let Word1{20-17} = 0; // BURST_COUNT
> diff --git a/test/CodeGen/R600/llvm.round.ll b/test/CodeGen/R600/llvm.round.ll
> index e06d45d..5700427 100644
> --- a/test/CodeGen/R600/llvm.round.ll
> +++ b/test/CodeGen/R600/llvm.round.ll
> @@ -1,11 +1,13 @@
> -; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s --check-prefix=R600 --check-prefix=FUNC
> +; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck %s --check-prefix=R600 --check-prefix=FUNC
>
> ; FUNC-LABEL: @f32
> -; R600: FRACT
> -; R600-DAG: ADD
> -; R600-DAG: CEIL
> -; R600-DAG: FLOOR
> -; R600: CNDGE
> +; R600: FRACT {{.*}}, [[ARG:KC[0-9]\[[0-9]+\]\.[XYZW]]]
> +; R600-DAG: ADD {{.*}}, -0.5
> +; R600-DAG: CEIL {{.*}} [[ARG]]
> +; R600-DAG: FLOOR {{.*}} [[ARG]]
> +; R600-DAG: CNDGE
> +; R600-DAG: CNDGT
> +; R600: CNDGE {{[^,]+}}, [[ARG]]
> define void @f32(float addrspace(1)* %out, float %in) {
> entry:
> %0 = call float @llvm.round.f32(float %in)
> --
> 1.9.3
>
More information about the llvm-commits
mailing list