This is the mail archive of the
mailing list for the GCC project.
RE: [RFC] Unsolicited usage of VFP registers for Cortex-M4F
- From: "Joey Ye" <joey dot ye at arm dot com>
- To: "'Ilija Kocho'" <ilijak at siva dot com dot mk>
- Cc: <gcc-help at gcc dot gnu dot org>, "Terry Guo" <Terry dot Guo at arm dot com>
- Date: Tue, 9 Oct 2012 18:21:41 +0800
- Subject: RE: [RFC] Unsolicited usage of VFP registers for Cortex-M4F
- References: <firstname.lastname@example.org> <5073F94F.email@example.com>
> -----Original Message-----
> From: Ilija Kocho [mailto:firstname.lastname@example.org]
> Sent: Tuesday, October 09, 2012 18:16
> To: Joey Ye
> Cc: email@example.com; Terry Guo
> Subject: Re: [RFC] Unsolicited usage of VFP registers for Cortex-M4F
> Hi Joey
> Here I forward you the email that I have posted to GCC help mailing
> On 24.09.2012 12:30, Ilija Kocho wrote:
> > Hi colleagues
> > In a course of implementing lazy context switching I the following
> > come to me:
> > Here is a quote in case the link renders broken (in future):
> > -- Quote ------------
> > GNUC C compiler (gcc)
> > If a program is compiled with the FPU option, gcc might make use of
> > floating-point registers if register pressure is high, and running
> > on available registers for data processing. In some cases, the memory
> > copy might also utilize floating-point registers to hold data.
> > It is possible to avoid the use of floating-point instructions in
> > non-floating-point code by using |-mfloat-abi=soft|.
> > By default, libraries are built with |-mfloat-abi=soft|. So they must
> > not contain floating-point instructions. However, because there are
> > various gcc vendors with different build options, you might have to
> > check with your gcc tool chain supplier to find out the status of the
> > libraries.
> > -- end of quote ---------
> > I did some research, googling and searching GCC mailing lists, and
> > no other reference that would confirm/deny or put some light on above
> > Therefore here are my questions:
> > 1) Does GCC use VFP registers for holding data other than floating
> > values (unsolicited VFP usage)?
It doesn't so far. Although GCC has no problem use FP for non-FP, the cost
model in ARM backend says using VFP isn't performing better than otherwise.
For Cortex-M4F this isn't the best approach. I worked out a patch to tune
the cost model for M4F together with an option to enable/disable it. I'm
hoping to submit it later this year and it should enable Cortex-M4F to use
VFP extensively for non-FP data when option enabled.
> > If (1) is true:
> > 1.1) What conditions, in addition to selecting -mfloat-abi=hard (or
> > softfp) shall cause such behaviour. I would appreciate some test case.
When the patch is upstreamed, and given that -ffpreg-for-nonfpdata is
provided, VFP will be used for non-FP data when ever register pressure is
> > 1.2) Any pointer to source code responsible for this [optimization]?
> > would appreciate this.
You can take a look at arm_register_move_cost. But there is more work to do
as a couple of reload hooks need to be fixed before it works correctly.
> > 1.4) Can it be disabled? I found no such command line option for ARM
> > targets.
The command line will be as -f[no-]fpreg-for-nonfpdata
> > 2) Above quote states that -mfloat-abi=soft should be used for libs,
> > ld refuses to link them with code produced with -mfloat-abi=hard even
> > the libs do not use floating point operations. Is there a waay to
> > this?
The quote isn't accurate nowadays. More and more libraries are built with
hard. Also a mechanism called multilib enables you to pick soft or hard
automatically according to linker command line
> > I am especially intersted for Cortex-M4F architecture, but also I
> > like to know about ARMv7 in general.
> > Regards
> > Ilija
Thanks - Joey