> -----Original Message----- > From: Ilija Kocho [mailto:ilijak@xxxxxxxxxxx] > Sent: Tuesday, October 09, 2012 18:16 > To: Joey Ye > Cc: gcc-help@xxxxxxxxxxx; 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 > list > recently. > > Ilija > > On 24.09.2012 12:30, Ilija Kocho wrote: > > Hi colleagues > > > > In a course of implementing lazy context switching I the following > link > > come to me: > > > http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0298a/DA > FIFGGE.html > > > > 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 > the > > floating-point registers if register pressure is high, and running > low > > 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 > found > > no other reference that would confirm/deny or put some light on above > text. > > > > Therefore here are my questions: > > > > 1) Does GCC use VFP registers for holding data other than floating > point > > 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 high. > > 1.2) Any pointer to source code responsible for this [optimization]? > I > > 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, > but > > ld refuses to link them with code produced with -mfloat-abi=hard even > if > > the libs do not use floating point operations. Is there a waay to > tweak > > 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 > would > > like to know about ARMv7 in general. > > > > Regards > > Ilija > > > Thanks - Joey