On Thu, Jul 7, 2011 at 12:29 AM, Michael Meissner <meiss...@linux.vnet.ibm.com> wrote: > This patch adds an option to not load the static chain (r11) for 64-bit > PowerPC > calls through function pointers (or virtual function). Most of the languages > on the PowerPC do not need the static chain being loaded when called, and > adding this instruction can slow down code that calls very short functions. > > In addition, if the function does not call alloca, setjmp or deal with > exceptions where the stack is modified, the compiler can move the store of the > TOC value for the current function to the prologue of the function, rather > than > at each call site. > > The effect of these patches is to speed up 464.h264ref in the Spec 2006 > benchmark by about 7% if -mno-r11 is used, and 5% if it is not used (but the > save of the TOC register is hoisted). I believe this is due to the load of > the > current function's TOC (r2) having to wait until the store queue is drained > with the store just before the call. > > Unfortunately, I do see a 3% slowdown in 429.mcf, which I don't know what the > cause is. > > I have bootstraped the compiler and saw that there were no regressions in make > check. Is it ok to install in the trunk?
Hum. Can't the compiler figure this our itself per-call-site? At least the name of the command-line switch -m[no-]r11 is meaningless to me. Points-to information should be able to tell you if the function pointer points to a nested function. Richard. > [gcc] > 2011-07-06 Michael Meissner <meiss...@linux.vnet.ibm.com> > > * config/rs6000/rs6000-protos.h (rs6000_call_indirect_aix): New > declaration. > (rs6000_save_toc_in_prologue_p): Ditto. > > * config/rs6000/rs6000.opt (-mr11): New switch to disable loading > up the static chain (r11) during indirect function calls. > (-msave-toc-indirect): New undocumented debug switch. > > * config/rs6000/rs6000.c (struct machine_function): Add > save_toc_in_prologue field to note whether the prologue needs to > save the TOC value in the reserved stack location. > (rs6000_emit_prologue): Use TOC_REGNUM instead of 2. If we need > to save the TOC in the prologue, do so. > (rs6000_trampoline_init): Don't allow creating AIX style > trampolines if -mno-r11 is in effect. > (rs6000_call_indirect_aix): New function to create AIX style > indirect calls, adding support for -mno-r11 to suppress loading > the static chain, and saving the TOC in the prologue instead of > the call body. > (rs6000_save_toc_in_prologue_p): Return true if we are saving the > TOC in the prologue. > > * config/rs6000/rs6000.md (STACK_POINTER_REGNUM): Add more fixed > register numbers. > (TOC_REGNUM): Ditto. > (STATIC_CHAIN_REGNUM): Ditto. > (ARG_POINTER_REGNUM): Ditto. > (SFP_REGNO): Delete, unused. > (TOC_SAVE_OFFSET_32BIT): Add constants for AIX TOC save and > function descriptor offsets. > (TOC_SAVE_OFFSET_64BIT): Ditto. > (AIX_FUNC_DESC_TOC_32BIT): Ditto. > (AIX_FUNC_DESC_TOC_64BIT): Ditto. > (AIX_FUNC_DESC_SC_32BIT): Ditto. > (AIX_FUNC_DESC_SC_64BIT): Ditto. > (ptrload): New mode attribute for the appropriate load of a > pointer. > (call_indirect_aix32): Delete, rewrite AIX indirect function > calls. > (call_indirect_aix64): Ditto. > (call_value_indirect_aix32): Ditto. > (call_value_indirect_aix64): Ditto. > (call_indirect_nonlocal_aix32_internal): Ditto. > (call_indirect_nonlocal_aix32): Ditto. > (call_indirect_nonlocal_aix64_internal): Ditto. > (call_indirect_nonlocal_aix64): Ditto. > (call): Rewrite AIX indirect function calls. Add support for > eliminating the static chain, and for moving the save of the TOC > to the function prologue. > (call_value): Ditto. > (call_indirect_aix<ptrsize>): Ditto. > (call_indirect_aix<ptrsize>_internal): Ditto. > (call_indirect_aix<ptrsize>_internal2): Ditto. > (call_indirect_aix<ptrsize>_nor11): Ditto. > (call_value_indirect_aix<ptrsize>): Ditto. > (call_value_indirect_aix<ptrsize>_internal): Ditto. > (call_value_indirect_aix<ptrsize>_internal2): Ditto. > (call_value_indirect_aix<ptrsize>_nor11): Ditto. > (call_nonlocal_aix32): Relocate in the rs6000.md file. > (call_nonlocal_aix64): Ditto. > > * doc/invoke.texi (RS/6000 and PowerPC Options): Add -mr11 and > -mno-r11 documentation. > [gcc/testsuite] > 2011-07-06 Michael Meissner <meiss...@linux.vnet.ibm.com> > > * gcc.target/powerpc/no-r11-1.c: New test for -mr11, -mno-r11. > * gcc.target/powerpc/no-r11-2.c: Ditto. > * gcc.target/powerpc/no-r11-3.c: Ditto. > > -- > Michael Meissner, IBM > 5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA > meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899 >