Spencer Abson <spencer.ab...@arm.com> writes:
> Enable a target with FEAT_FP16 to emit the half-precision variants
> of FCMP/FCMPE.
>
> gcc/ChangeLog:
>
>       * config/aarch64/aarch64.md: Update cbranch, cstore, fcmp
>       and fcmpe to use the GPF_F16 iterator for floating-point
>       modes.
>
> gcc/testsuite/ChangeLog:
>
>       * gcc.target/aarch64/_Float16_cmp_1.c: New test.
>       * gcc.target/aarch64/_Float16_cmp_2.c: New (negative) test.
> ---
>  gcc/config/aarch64/aarch64.md                 | 29 +++++-----
>  .../gcc.target/aarch64/_Float16_cmp_1.c       | 54 +++++++++++++++++++
>  .../gcc.target/aarch64/_Float16_cmp_2.c       |  7 +++
>  3 files changed, 77 insertions(+), 13 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/aarch64/_Float16_cmp_1.c
>  create mode 100644 gcc/testsuite/gcc.target/aarch64/_Float16_cmp_2.c
>
> diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
> index 071058dbeb3..8721bf5d4f3 100644
> --- a/gcc/config/aarch64/aarch64.md
> +++ b/gcc/config/aarch64/aarch64.md
> @@ -707,11 +707,12 @@
>  )
>  
>  (define_expand "cbranch<mode>4"
> -  [(set (pc) (if_then_else (match_operator 0 "aarch64_comparison_operator"
> -                         [(match_operand:GPF 1 "register_operand")
> -                          (match_operand:GPF 2 
> "aarch64_fp_compare_operand")])
> -                        (label_ref (match_operand 3 "" ""))
> -                        (pc)))]
> +  [(set (pc) (if_then_else
> +             (match_operator 0 "aarch64_comparison_operator"
> +              [(match_operand:GPF_F16 1 "register_operand")
> +               (match_operand:GPF_F16 2 "aarch64_fp_compare_operand")])
> +             (label_ref (match_operand 3 "" ""))
> +             (pc)))]
>    ""
>    "
>    operands[1] = aarch64_gen_compare_reg (GET_CODE (operands[0]), operands[1],
> @@ -4338,26 +4339,28 @@
>  
>  (define_insn "fcmp<mode>"
>    [(set (reg:CCFP CC_REGNUM)
> -        (compare:CCFP (match_operand:GPF 0 "register_operand")
> -                   (match_operand:GPF 1 "aarch64_fp_compare_operand")))]
> +     (compare:CCFP
> +             (match_operand:GPF_F16 0 "register_operand")
> +             (match_operand:GPF_F16 1 "aarch64_fp_compare_operand")))]

Minor formatting nit, but it'd be more usual to indent by two extra
columns relative to the (compare ...), i.e.:

        (compare:CCFP
          (match_operand:GPF_F16 0 "register_operand")
          (match_operand:GPF_F16 1 "aarch64_fp_compare_operand")))]

Similarly for the others.

OK with that change for GCC 16, thanks.

BTW:

> diff --git a/gcc/testsuite/gcc.target/aarch64/_Float16_cmp_2.c 
> b/gcc/testsuite/gcc.target/aarch64/_Float16_cmp_2.c
> new file mode 100644
> index 00000000000..e714304970b
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/_Float16_cmp_2.c
> @@ -0,0 +1,7 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -march=armv8.2-a+nofp16" } */
> +
> +#include "_Float16_cmp_1.c"
> +
> +/* { dg-final { scan-assembler-not "\tfcmp\th\[0-9\]\+" } } */
> +/* { dg-final { scan-assembler-not "\tfcmpe\th\[0-9\]\+" } } */
> \ No newline at end of file

It can be easier to write these tests using {...} quoting for the regexp
as well, so that backslashes are regexp backslashes rather than Tcl string
backslashes:

/* { dg-final { scan-assembler-not {\tfcmp\th[0-9]+} } } */
/* { dg-final { scan-assembler-not {\tfcmpe\th[0-9]+} } } */

The "..." version is ok (and often used) too though.

Richard

Reply via email to