[llvm-commits] patch: PUSH/POP optimization for THUMB

liangh at codeaurora.org liangh at codeaurora.org
Fri Oct 19 16:04:58 PDT 2012


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-PUSH-POP-Optimization.patch
Type: application/octet-stream
Size: 14334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121019/63234fdb/attachment.obj>


More information about the llvm-commits mailing list