From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35799 invoked by alias); 12 Nov 2015 21:52:24 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 35765 invoked by uid 89); 12 Nov 2015 21:52:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 12 Nov 2015 21:52:22 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 6E16B330DB95 for ; Thu, 12 Nov 2015 22:52:18 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7xxkFYtQRWGe for ; Thu, 12 Nov 2015 22:52:18 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 4DBF4330DB94 for ; Thu, 12 Nov 2015 22:52:18 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [sparc] Rotate stack checking loop Date: Thu, 12 Nov 2015 21:52:00 -0000 Message-ID: <4859624.RrIqjZSzxc@polaris> User-Agent: KMail/4.14.9 (Linux/3.16.7-29-desktop; KDE/4.14.9; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1848823.MzbumiMgff" Content-Transfer-Encoding: 7Bit X-SW-Source: 2015-11/txt/msg01601.txt.bz2 This is a multi-part message in MIME format. --nextPart1848823.MzbumiMgff Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Content-length: 639 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 SPARC/Solaris, to be applied on the mainline. 2015-11-12 Eric Botcazou * config/sparc/sparc.c (sparc_emit_probe_stack_range): Adjust. (output_probe_stack_range): Rotate the loop and simplify. -- Eric Botcazou --nextPart1848823.MzbumiMgff Content-Disposition: attachment; filename="rotate_sparc.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="utf-8"; name="rotate_sparc.diff" Content-length: 2233 Index: config/sparc/sparc.c =================================================================== --- config/sparc/sparc.c (revision 230204) +++ config/sparc/sparc.c (working copy) @@ -5058,9 +5058,9 @@ sparc_emit_probe_stack_range (HOST_WIDE_ emit_stack_probe (plus_constant (Pmode, g1, -size)); } - /* The run-time loop is made up of 10 insns in the generic case while the + /* The run-time loop is made up of 9 insns in the generic case while the compile-time loop is made up of 4+2*(n-2) insns for n # of intervals. */ - else if (size <= 5 * PROBE_INTERVAL) + else if (size <= 4 * PROBE_INTERVAL) { HOST_WIDE_INT i; @@ -5147,41 +5147,33 @@ 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 ("add\t%0, %1, %0", xops); + + /* Test if TEST_ADDR == LAST_ADDR. */ xops[1] = reg2; output_asm_insn ("cmp\t%0, %1", xops); - if (TARGET_ARCH64) - fputs ("\tbe,pn\t%xcc,", asm_out_file); - else - fputs ("\tbe\t", 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 (" add\t%0, %1, %0", xops); /* Probe at TEST_ADDR and branch. */ if (TARGET_ARCH64) - fputs ("\tba,pt\t%xcc,", asm_out_file); + fputs ("\tbne,pt\t%xcc,", asm_out_file); else - fputs ("\tba\t", asm_out_file); + fputs ("\tbne\t", asm_out_file); assemble_name_raw (asm_out_file, loop_lab); fputc ('\n', asm_out_file); xops[1] = GEN_INT (SPARC_STACK_BIAS); output_asm_insn (" st\t%%g0, [%0+%1]", xops); - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, end_lab); - return ""; } --nextPart1848823.MzbumiMgff--