Missed optimization - unnecessary PUSH/POP
Bug #1720872 reported by
Dan Lewis
This bug report was converted into a question: question #681994: Missed optimization - unnecessary PUSH/POP.
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
GNU Arm Embedded Toolchain |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I found two examples of where gcc -O3 produces a PUSH / POP sequence that unnecessarily includes register R3. According to the ARM Procedure Call Standard, register R3 does not need to be preserved by functions.
An example of the C source code and the resulting ARM assembly can be found here:
This is with version 5.4 of gcc and using the following command line options:
-O3 -march=armv7-m -mtune=cortex-m4 -mthumb
Changed in gcc-arm-embedded: | |
status: | New → Invalid |
To post a comment you must log in.
Hi,
GCC often pushes r3 to ensure that the stack is 8byte aligned at function call boundary. If an odd number of register needs to be saved, GCC will also push r3 to make it even and thus keep the stack pointer 8byte aligned.
Let me know if this is what happens for you.
Best regards,
Thomas