[PATCH 2/2][Aarch64] Improve FP to int conversions
Michael Collison
Michael.Collison@arm.com
Fri May 18 21:34:00 GMT 2018
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.collison@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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gnutools-6527-pt2.patch
Type: application/octet-stream
Size: 3091 bytes
Desc: gnutools-6527-pt2.patch
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180518/c711ac90/attachment.obj>
More information about the Gcc-patches
mailing list