From patchwork Sat Sep 3 16:28:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 113239 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 67DF1B6F71 for ; Sun, 4 Sep 2011 02:28:32 +1000 (EST) Received: (qmail 32366 invoked by alias); 3 Sep 2011 16:28:29 -0000 Received: (qmail 32344 invoked by uid 22791); 3 Sep 2011 16:28:28 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from hiauly1.hia.nrc.ca (HELO hiauly1.hia.nrc.ca) (132.246.10.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 03 Sep 2011 16:28:09 +0000 Received: by hiauly1.hia.nrc.ca (Postfix, from userid 1000) id 0E3384DD1; Sat, 3 Sep 2011 12:28:07 -0400 (EDT) Date: Sat, 3 Sep 2011 12:28:07 -0400 From: John David Anglin To: gcc-patches@gcc.gnu.org Subject: [committed] Define "return" pattern on pa Message-ID: <20110903162806.GA11449@hiauly1.hia.nrc.ca> Reply-To: John David Anglin MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.16 (2007-06-09) 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 This change defines a "return" insn pattern on pa to improve return optimization when no epilogue is needed. Tested on hppa2.0w-hp-hpux11.11 and hppa-unknown-linux-gnu. Committed to trunk. Defining a "return" pattern fixes PR middle-end/50232 on PA. Dave Index: config/pa/pa.md =================================================================== --- config/pa/pa.md (revision 178315) +++ config/pa/pa.md (working copy) @@ -6671,6 +6671,20 @@ ;; Unconditional and other jump instructions. +;; Trivial return used when no epilogue is needed. +(define_insn "return" + [(return) + (use (reg:SI 2))] + "pa_can_use_return_insn ()" + "* +{ + if (TARGET_PA_20) + return \"bve%* (%%r2)\"; + return \"bv%* %%r0(%%r2)\"; +}" + [(set_attr "type" "branch") + (set_attr "length" "4")]) + ;; This is used for most returns. (define_insn "return_internal" [(return) @@ -6719,11 +6733,8 @@ rtx x; /* Try to use the trivial return first. Else use the full epilogue. */ - if (reload_completed - && !frame_pointer_needed - && !df_regs_ever_live_p (2) - && (compute_frame_size (get_frame_size (), 0) ? 0 : 1)) - x = gen_return_internal (); + if (pa_can_use_return_insn ()) + x = gen_return (); else { hppa_expand_epilogue (); Index: config/pa/pa-protos.h =================================================================== --- config/pa/pa-protos.h (revision 178315) +++ config/pa/pa-protos.h (working copy) @@ -93,6 +93,7 @@ extern int cint_ok_for_move (HOST_WIDE_INT); extern void hppa_expand_prologue (void); extern void hppa_expand_epilogue (void); +extern bool pa_can_use_return_insn (void); extern int ior_mask_p (unsigned HOST_WIDE_INT); extern void compute_zdepdi_operands (unsigned HOST_WIDE_INT, unsigned *); Index: config/pa/pa.c =================================================================== --- config/pa/pa.c (revision 178315) +++ config/pa/pa.c (working copy) @@ -4329,6 +4329,24 @@ } } +bool +pa_can_use_return_insn (void) +{ + if (!reload_completed) + return false; + + if (frame_pointer_needed) + return false; + + if (df_regs_ever_live_p (2)) + return false; + + if (crtl->profile) + return false; + + return compute_frame_size (get_frame_size (), 0) == 0; +} + rtx hppa_pic_save_rtx (void) {