* [mips] Rotate stack checking loop
@ 2015-11-12 21:52 Eric Botcazou
2015-12-02 15:36 ` Moore, Catherine
0 siblings, 1 reply; 2+ messages in thread
From: Eric Botcazou @ 2015-11-12 21:52 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 744 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).
Unfortunately I don't have access to MIPS hardware any more so I only verified
that the assembly code is as expected and can be assembled. OK for mainline?
2015-11-12 Eric Botcazou <ebotcazou@adacore.com>
* config/mips/mips.c (mips_emit_probe_stack_range): Adjust.
(mips_output_probe_stack_range): Rotate the loop and simplify.
--
Eric Botcazou
[-- Attachment #2: rotate_mips.diff --]
[-- Type: text/x-patch, Size: 1981 bytes --]
Index: config/mips/mips.c
===================================================================
--- config/mips/mips.c (revision 230204)
+++ config/mips/mips.c (working copy)
@@ -11335,11 +11335,12 @@ mips_emit_probe_stack_range (HOST_WIDE_I
/* 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. */
@@ -11365,38 +11366,31 @@ const char *
mips_output_probe_stack_range (rtx reg1, rtx reg2)
{
static int labelno = 0;
- char loop_lab[32], end_lab[32], tmp[64];
+ char loop_lab[32], tmp[64];
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. */
- xops[0] = reg1;
- xops[1] = reg2;
- strcpy (tmp, "%(%<beq\t%0,%1,");
- output_asm_insn (strcat (tmp, &end_lab[1]), xops);
-
/* TEST_ADDR = TEST_ADDR + PROBE_INTERVAL. */
+ xops[0] = reg1;
xops[1] = GEN_INT (-PROBE_INTERVAL);
if (TARGET_64BIT && TARGET_LONG64)
output_asm_insn ("daddiu\t%0,%0,%1", xops);
else
output_asm_insn ("addiu\t%0,%0,%1", xops);
- /* Probe at TEST_ADDR and branch. */
- fprintf (asm_out_file, "\tb\t");
- assemble_name_raw (asm_out_file, loop_lab);
- fputc ('\n', asm_out_file);
+ /* Probe at TEST_ADDR, test if TEST_ADDR == LAST_ADDR and branch. */
+ xops[1] = reg2;
+ strcpy (tmp, "%(%<bne\t%0,%1,");
+ output_asm_insn (strcat (tmp, &loop_lab[1]), xops);
if (TARGET_64BIT)
output_asm_insn ("sd\t$0,0(%0)%)", xops);
else
output_asm_insn ("sw\t$0,0(%0)%)", xops);
- ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, end_lab);
-
return "";
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [mips] Rotate stack checking loop
2015-11-12 21:52 [mips] Rotate stack checking loop Eric Botcazou
@ 2015-12-02 15:36 ` Moore, Catherine
0 siblings, 0 replies; 2+ messages in thread
From: Moore, Catherine @ 2015-12-02 15:36 UTC (permalink / raw)
To: Eric Botcazou, gcc-patches; +Cc: Matthew Fortune
> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> owner@gcc.gnu.org] On Behalf Of Eric Botcazou
> Sent: Thursday, November 12, 2015 4:51 PM
> To: gcc-patches@gcc.gnu.org
> Subject: [mips] Rotate stack checking loop
>
> 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).
>
> Unfortunately I don't have access to MIPS hardware any more so I only
> verified
> that the assembly code is as expected and can be assembled. OK for
> mainline?
>
>
> 2015-11-12 Eric Botcazou <ebotcazou@adacore.com>
>
> * config/mips/mips.c (mips_emit_probe_stack_range): Adjust.
> (mips_output_probe_stack_range): Rotate the loop and simplify.
>
This is OK.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-02 15:36 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 [mips] Rotate stack checking loop Eric Botcazou
2015-12-02 15:36 ` Moore, Catherine
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).