* [rs6000] Rotate stack checking loop
@ 2015-11-12 21:52 Eric Botcazou
2015-11-12 21:56 ` David Edelsohn
0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2015-11-12 21:52 UTC (permalink / raw)
To: gcc-patches; +Cc: David Edelsohn
[-- Attachment #1: Type: text/plain, Size: 631 bytes --]
Hi,
this patch rotates the loop generated in the prologue to do stack checking
when -fstack-check is specified, thereby saving one branch instruction. It
was initially implemented as a WHILE loop to match the generic implementation
but can be turned into a DO-WHILE loop because the amount of stack to be
checked is known at compile time (since it's the static part of the frame).
Tested on PowerPC/Linux, OK for the mainline?
2015-11-12 Eric Botcazou <ebotcazou@adacore.com>
* config/rs6000/rs6000.c (rs6000_emit_probe_stack_rang): Adjust.
(output_probe_stack_range): Rotate the loop and simplify.
--
Eric Botcazou
[-- Attachment #2: rotate_ppc.diff --]
[-- Type: text/x-patch, Size: 2122 bytes --]
Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c (revision 230204)
+++ config/rs6000/rs6000.c (working copy)
@@ -23988,11 +23988,12 @@ rs6000_emit_probe_stack_range (HOST_WIDE
/* Step 3: the loop
- while (TEST_ADDR != LAST_ADDR)
+ do
{
TEST_ADDR = TEST_ADDR + PROBE_INTERVAL
probe at TEST_ADDR
}
+ while (TEST_ADDR != LAST_ADDR)
probes at FIRST + N * PROBE_INTERVAL for values of N from 1
until it is equal to ROUNDED_SIZE. */
@@ -24018,39 +24019,35 @@ const char *
output_probe_stack_range (rtx reg1, rtx reg2)
{
static int labelno = 0;
- char loop_lab[32], end_lab[32];
+ char loop_lab[32];
rtx xops[2];
- ASM_GENERATE_INTERNAL_LABEL (loop_lab, "LPSRL", labelno);
- ASM_GENERATE_INTERNAL_LABEL (end_lab, "LPSRE", labelno++);
+ ASM_GENERATE_INTERNAL_LABEL (loop_lab, "LPSRL", labelno++);
+ /* Loop. */
ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, loop_lab);
- /* Jump to END_LAB if TEST_ADDR == LAST_ADDR. */
+ /* TEST_ADDR = TEST_ADDR + PROBE_INTERVAL. */
xops[0] = reg1;
+ xops[1] = GEN_INT (-PROBE_INTERVAL);
+ output_asm_insn ("addi %0,%0,%1", xops);
+
+ /* Probe at TEST_ADDR. */
+ xops[1] = gen_rtx_REG (Pmode, 0);
+ output_asm_insn ("stw %1,0(%0)", xops);
+
+ /* Test if TEST_ADDR == LAST_ADDR. */
xops[1] = reg2;
if (TARGET_64BIT)
output_asm_insn ("cmpd 0,%0,%1", xops);
else
output_asm_insn ("cmpw 0,%0,%1", xops);
- fputs ("\tbeq 0,", asm_out_file);
- assemble_name_raw (asm_out_file, end_lab);
- fputc ('\n', asm_out_file);
-
- /* TEST_ADDR = TEST_ADDR + PROBE_INTERVAL. */
- xops[1] = GEN_INT (-PROBE_INTERVAL);
- output_asm_insn ("addi %0,%0,%1", xops);
-
- /* Probe at TEST_ADDR and branch. */
- xops[1] = gen_rtx_REG (Pmode, 0);
- output_asm_insn ("stw %1,0(%0)", xops);
- fprintf (asm_out_file, "\tb ");
+ /* Branch. */
+ fputs ("\tbne 0,", asm_out_file);
assemble_name_raw (asm_out_file, loop_lab);
fputc ('\n', asm_out_file);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, end_lab);
-
return "";
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [rs6000] Rotate stack checking loop
2015-11-12 21:52 [rs6000] Rotate stack checking loop Eric Botcazou
@ 2015-11-12 21:56 ` David Edelsohn
0 siblings, 0 replies; 2+ messages in thread
From: David Edelsohn @ 2015-11-12 21:56 UTC (permalink / raw)
To: Eric Botcazou; +Cc: GCC Patches
On Thu, Nov 12, 2015 at 4:51 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> this patch rotates the loop generated in the prologue to do stack checking
> when -fstack-check is specified, thereby saving one branch instruction. It
> was initially implemented as a WHILE loop to match the generic implementation
> but can be turned into a DO-WHILE loop because the amount of stack to be
> checked is known at compile time (since it's the static part of the frame).
>
> Tested on PowerPC/Linux, OK for the mainline?
>
>
> 2015-11-12 Eric Botcazou <ebotcazou@adacore.com>
>
> * config/rs6000/rs6000.c (rs6000_emit_probe_stack_rang): Adjust.
> (output_probe_stack_range): Rotate the loop and simplify.
Okay.
Thanks, David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-12 21:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 21:52 [rs6000] Rotate stack checking loop Eric Botcazou
2015-11-12 21:56 ` David Edelsohn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).