Like https://gcc.gnu.org/ml/gcc-patches/2010-09/msg00060.html for PowerPC, we should do something similar for aarch64. This pattern does show up in SPEC CPU 2006 in astar but I did not look into performance improvement of it though.
OK? Bootstrapped and tested on aarch64-linux-gnu with no regressions. Thanks, Andrew Pinski ChangeLog: * config/aarch64/aarch64.md (*frintz): New pattern. testsuite/ChangeLog: * testsuite/gcc.target/aarch64/floattointtofloat-1.c: New testcase.
commit 9cef5e196729df5a197b81b72192d687683a057a Author: Andrew Pinski <apin...@cavium.com> Date: Thu Aug 17 22:31:15 2017 -0700 Fix 19869: (double)(long)double_var could be better optimized Use FRINTZ to optimize this. Signed-off-by: Andrew Pinski <apin...@cavium.com> diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index 5e6b027..1439bd0 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -4645,6 +4645,16 @@ [(set_attr "type" "f_cvti2f")] ) +(define_insn "*frintz" + [(set (match_operand:GPF 0 "register_operand" "=w") + (float:GPF (fix:GPI (match_operand:GPF 1 "register_operand" "w"))))] + "TARGET_FLOAT && flag_unsafe_math_optimizations && !flag_trapping_math" + "frintz %<GPF:s>0, %<GPF:s>1" + [(set_attr "simd" "yes") + (set_attr "fp" "no") + (set_attr "type" "neon_int_to_fp_<Vetype>")] +) + ;; If we do not have ARMv8.2-A 16-bit floating point extensions, the ;; midend will arrange for an SImode conversion to HFmode to first go ;; through DFmode, then to HFmode. But first it will try converting diff --git a/gcc/testsuite/gcc.target/aarch64/floattointtofloat-1.c b/gcc/testsuite/gcc.target/aarch64/floattointtofloat-1.c new file mode 100644 index 0000000..c1209c6 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/floattointtofloat-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast" } */ +double dll(double a) +{ + return (long long)a; +} +double di(double a) +{ + return (int)a; +} +float fll(float a) +{ + return (long long)a; +} +float fi(float a) +{ + return (int)a; +} +/* { dg-final { scan-assembler-times "frintz" 4 } } */ +