From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 35902 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 35803 invoked by uid 89); 12 Nov 2015 21:52:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_40,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 2337D330DB99 for ; Thu, 12 Nov 2015 22:52:20 +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 3T6FBxpg2iLn for ; Thu, 12 Nov 2015 22:52:20 +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 F0F2D330DB94 for ; Thu, 12 Nov 2015 22:52:19 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [ia64] Rotate stack checking loop Date: Thu, 12 Nov 2015 21:52:00 -0000 Message-ID: <4811216.abbgit2rQF@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="nextPart4284840.PoWXdW4ldF" Content-Transfer-Encoding: 7Bit X-SW-Source: 2015-11/txt/msg01604.txt.bz2 This is a multi-part message in MIME format. --nextPart4284840.PoWXdW4ldF Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Content-length: 694 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). The patch also fixes an error in the instruction count for the loop. Tested on IA-64/Linux, OK for the mainline? 2015-11-12 Eric Botcazou * config/ia64/ia64.c (ia64_emit_probe_stack_range): Adjust. (output_probe_stack_range): Rotate the loop and simplify. -- Eric Botcazou --nextPart4284840.PoWXdW4ldF Content-Disposition: attachment; filename="rotate_ia64.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="utf-8"; name="rotate_ia64.diff" Content-length: 2511 Index: config/ia64/ia64.c =================================================================== --- config/ia64/ia64.c (revision 230204) +++ config/ia64/ia64.c (working copy) @@ -3293,7 +3293,7 @@ ia64_emit_probe_stack_range (HOST_WIDE_I else if (size <= PROBE_INTERVAL) emit_stack_probe (r2); - /* The run-time loop is made up of 8 insns in the generic case while this + /* The run-time loop is made up of 9 insns in the generic case while this compile-time loop is made up of 5+2*(n-2) insns for n # of intervals. */ else if (size <= 4 * PROBE_INTERVAL) { @@ -3356,11 +3356,12 @@ ia64_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. */ @@ -3391,36 +3392,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[3]; - 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; - xops[2] = gen_rtx_REG (BImode, PR_REG (6)); - output_asm_insn ("cmp.eq %2, %I2 = %0, %1", xops); - fprintf (asm_out_file, "\t(%s) br.cond.dpnt ", reg_names [REGNO (xops[2])]); - assemble_name_raw (asm_out_file, end_lab); - fputc ('\n', asm_out_file); - /* TEST_ADDR = TEST_ADDR + PROBE_INTERVAL. */ + xops[0] = reg1; xops[1] = GEN_INT (-PROBE_INTERVAL); output_asm_insn ("addl %0 = %1, %0", xops); fputs ("\t;;\n", asm_out_file); - /* Probe at TEST_ADDR and branch. */ + /* Probe at TEST_ADDR. */ output_asm_insn ("probe.w.fault %0, 0", xops); - fprintf (asm_out_file, "\tbr "); + + /* Test if TEST_ADDR == LAST_ADDR. */ + xops[1] = reg2; + xops[2] = gen_rtx_REG (BImode, PR_REG (6)); + output_asm_insn ("cmp.eq %2, %I2 = %0, %1", xops); + + /* Branch. */ + fprintf (asm_out_file, "\t(%s) br.cond.dpnt ", reg_names [PR_REG (7)]); assemble_name_raw (asm_out_file, loop_lab); fputc ('\n', asm_out_file); - ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, end_lab); - return ""; } --nextPart4284840.PoWXdW4ldF--