This patch improves additional cases of FP to integer conversions with 
-ffast-math enabled.

Example 1:

double
f5 (int x)
{
  return (double)(float) x;
}


At -O2 with -ffast-math

Trunk generates:

f5:
        scvtf   s0, w0
        fcvt    d0, s0
        ret


With the patch we can merge the conversion to float and float-extend and reduce 
the sequence to one instruction at -O2 and -ffast-math

f5:
        scvtf   d0, w0
        ret

Example 2

int
f6 (double x)
{
  return (int)(float) x;
}


At -O2 (even with -ffast-math) trunk generates

f6:
        fcvt    s0, d0
        fcvtzs  w0, s0
        ret

We can merge the float_truncate into the fix at the rtl level

With -ffast-math enabled and -O2 we can now generate:

f6:
        fcvtzs  w0, d0
        ret
        
Bootstrapped and regression tested on aarch64-linux-gnu. Okay for trunk?

2018-05-15  Michael Collison  <michael.colli...@arm.com>

        * config/aarch64/aarch64.md:
        (*<optab><mode>df2): New pattern.
        (truncdfsf_<optab><mode>2: New pattern.
        (*fix_to_sign_extend<mode>di2): Ditto.
        * gcc.target/aarch64/float_int_conv.c: New testcase.

Attachment: gnutools-6527-pt2.patch
Description: gnutools-6527-pt2.patch

Reply via email to