[llvm-commits] patch: PUSH/POP optimization for THUMB
Evan Cheng
evan.cheng at apple.com
Sat Oct 20 11:13:35 PDT 2012
Hi Liang,
It seems the cost is too high for the reward. I understand the benefit of using a 16-bit instruction here but does this comes up frequently? I would have been ok with this if it's a localized change. But your proposal includes a target hook hasLiveStackObjects() that seems to serve no purpose other than this minor optimization. Is it possible for you to significantly simplify the patch?
Evan
On Oct 19, 2012, at 4:04 PM, liangh at codeaurora.org wrote:
> Hi,
>
> This patch implements a PUSH/POP optimization.
>
> Currently, LLVM pushes/pops a dummy register to keep the stack aligned
> when the number of registers need to be pushed/popped is an odd.
> For example: "r11" here is pushed as a pad to align the stack.
> ##################
> foo:
> push {r11, lr}
> sub sp, #8
> add r0, sp, #4
> bl goo
> add sp, #8
> pop {r11, pc}
> ##################
>
> Enabled by this patch, the stack can be padded to align if the PUSH
> instruction is followed by an SP-adjusting instruction, so that the
> useless efforts of storing and loading the dummy register can be saved.
> Also, a PUSH instruction can be encoded with 16 but not 32 bits if it is
> pushing a single register.
> For example, the above code will be changed to:
> ##################
> foo:
> push {lr}
> sub sp, #12
> add r0, sp, #4
> bl goo
> add sp, #12
> pop {pc}
> ##################
>
> This optimization only takes effect in thumb mode with a non-zero
> optimization level.
>
> Could you please review the attached patch?
> Thanks.
>
> -Liang<0001-PUSH-POP-Optimization.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list