This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Improve int<->FP conversions
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Michael Collison <Michael dot Collison at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Sun, 10 Sep 2017 22:42:12 -0700
- Subject: Re: Improve int<->FP conversions
- Authentication-results: sourceware.org; auth=none
- References: <HE1PR0802MB23772B0E8B8CC1D545A9F44C95680@HE1PR0802MB2377.eurprd08.prod.outlook.com>
On Sun, Sep 10, 2017 at 9:50 PM, Michael Collison
<Michael.Collison@arm.com> wrote:
> This patch improves the latency of code by eliminating two FP <-> integer register transfers.
>
> An example:
>
> float f1(float x)
> {
> int y = x;
> return (float)y;
> }
>
> Trunk generates:
>
> f1:
> fcvtzs w0, s0
> scvtf s0, w0
> ret
>
> With the patch we can use the neon scalar instructions and eliminate the two FP <-> integer register transfes.
>
> f1:
> fcvtzs s0, s0
> scvtf s0, s0
> ret
>
> Bootstrapped and tested on aarch64-linux-gnu. Okay for trunk?
>
> 2017-09-02 Michael Collison <michael.collison@arm.com>
>
> * config/aarch64/aarch64.md(<optab>_trunc><vf><GPI:mode>2):
> New pattern.
> (<optab>_trunchf<GPI:mode>2: New pattern.
> (<optab>_trunc<vgp><GPI:mode>2: New pattern.
You might want to set the simd and fp attr on these patterns but
other than I think this patch looks good (though I cannot approve it).
Thanks,
Andrew
> * config/aarch64/iterators.md (wv): New mode attribute.
> (vf, VF): New mode attributes.
> (vgp, VGP): New mode attributes.
> (s): Update attribute with SImode and DImode prefixes.
> * testsuite/gcc.target/aarch64/fix_trunc1.c: New testcase.