How to instruct GCC to allocate FPU registers for some variable?

Asked by grissiom

I'm optimizing some register-intensive code:

https://github.com/RT-Thread/RTGUI/blob/master/components/rtgui/common/dc_trans.c#L395

and found that the stack frame is too big(80 bytes) and the code seems to place lots of variables into the stack. Since memory access is much slower than registers, the interaction with stack becomes a bottleneck.

So I'm thinking that is there any way to tell GCC to allocate some variables into the FPU registers? I've declare some variables to be float to force GCC place them in the Sx registers instead of stack and obtained nearly 10% performance gain.

Is there a way to tell GCC automatically allocate the FPU register instead of the "hacks"?

Forgot to mention, my CPU is a Cortex-M4 and the CFLAGS is: -mcpu=cortex-m4 -mthumb -O2 -Ofast -mfloat-abi=hard -mfpu=fpv4-sp-d16

Question information

Language:
English Edit question
Status:
Answered
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Joey Ye (jinyun-ye) said :
#1

We are working on a feature to enable floating point register, which should try to put some integer data into FP registers. It improves some application but slows down some other. It is still under development yet.

If you can suggest which part of TH-Thread can be benefit from this feature, it will be helpful to get it adopted in GCC.

Thanks,
Joey

Revision history for this message
Joey Ye (jinyun-ye) said :
#2
Revision history for this message
grissiom (chaos.proton) said :
#3

Great News on that!

More over, if the stack is placed at the external RAM, allocating frequently accessed variables on the stack will be painful.

If you need demo code or some thing, feel free to ask on this thread or our BBS: http://www.rt-thread.org/phpBB3/ Thank you very much!

Can you help with this problem?

Provide an answer of your own, or ask grissiom for more information if necessary.

To post a message you must log in.