From patchwork Tue May 10 11:24:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 94968 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id CE07BB6F07 for ; Tue, 10 May 2011 21:23:55 +1000 (EST) Received: (qmail 13528 invoked by alias); 10 May 2011 11:23:52 -0000 Received: (qmail 13519 invoked by uid 22791); 10 May 2011 11:23:51 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 10 May 2011 11:23:32 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4ABNWEf012292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 10 May 2011 07:23:32 -0400 Received: from Gift.redhat.com (vpn1-7-105.ams2.redhat.com [10.36.7.105]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4ABNT4C017649 for ; Tue, 10 May 2011 07:23:31 -0400 From: Nick Clifton To: gcc-patches@gcc.gnu.org Subject: RX: Add jump and loop alignment Date: Tue, 10 May 2011 12:24:36 +0100 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi Guys, I am applying the patch below to the mainline and 4.6 branch. It was created by DJ Delorie to fix a performance regression with the RX port of GCC, compared to the 4.5 branch. The problem was that jumps and loops were not being aligned to an 8 byte boundary which can result in stalls whilst the instruction fetch stage fills the pipeline. Cheers Nick gcc/ChangeLog 2011-05-10 DJ Delorie * config/rx/rx.h (JUMP_ALIGN, LABEL_ALIGN, LOOP_ALIGN): Define. (LABEL_ALIGN_AFTER_BARRIER): Pass label to rx_align_for_label * config/rx/rx.c (rx_align_for_label): Add label and uses_threshold parameters. Do not align when the label is not used enough. * config/rx/rx-protos.h (rx_align_for_label): Update prototype. Index: gcc/config/rx/rx.h =================================================================== --- gcc/config/rx/rx.h (revision 173608) +++ gcc/config/rx/rx.h (working copy) @@ -617,7 +617,13 @@ #define SELECT_CC_MODE(OP,X,Y) rx_select_cc_mode((OP), (X), (Y)) -#define LABEL_ALIGN_AFTER_BARRIER(x) rx_align_for_label () +/* Compute the alignment needed for label X in various situations. + If the user has specified an alignment then honour that, otherwise + use rx_align_for_label. */ +#define JUMP_ALIGN(x) (align_jumps ? align_jumps : rx_align_for_label (x, 0)) +#define LABEL_ALIGN(x) (align_labels ? align_labels : rx_align_for_label (x, 3)) +#define LOOP_ALIGN(x) (align_loops ? align_loops : rx_align_for_label (x, 2)) +#define LABEL_ALIGN_AFTER_BARRIER(x) rx_align_for_label (x, 0) #define ASM_OUTPUT_MAX_SKIP_ALIGN(STREAM, LOG, MAX_SKIP) \ do \ Index: gcc/config/rx/rx-protos.h =================================================================== --- gcc/config/rx/rx-protos.h (revision 173608) +++ gcc/config/rx/rx-protos.h (working copy) @@ -30,7 +30,7 @@ extern int rx_initial_elimination_offset (int, int); #ifdef RTX_CODE -extern int rx_align_for_label (void); +extern int rx_align_for_label (rtx, int); extern void rx_emit_stack_popm (rtx *, bool); extern void rx_emit_stack_pushm (rtx *); extern void rx_expand_epilogue (bool); Index: gcc/config/rx/rx.c =================================================================== --- gcc/config/rx/rx.c (revision 173608) +++ gcc/config/rx/rx.c (working copy) @@ -2752,8 +2752,15 @@ int -rx_align_for_label (void) +rx_align_for_label (rtx lab, int uses_threshold) { + /* This is a simple heuristic to guess when an alignment would not be useful + because the delay due to the inserted NOPs would be greater than the delay + due to the misaligned branch. If uses_threshold is zero then the alignment + is always useful. */ + if (LABEL_NUSES (lab) < uses_threshold) + return 0; + return optimize_size ? 1 : 3; }