From patchwork Tue Oct 30 06:06:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 195293 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 5A7B32C00A3 for ; Tue, 30 Oct 2012 17:06:54 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352182014; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=9QUKtMsy86FFYt++Y2wHtr6XHSg=; b=gYGjSdpV0GoUmdX 1c8Pq+2Gr1zBhI8Ue8xA/wdUcf/IRb7J2dpx3cB/Cm+LTMyq6MoHm61CmXzqupmQ 6Sm0AQUNw31iS5qE+21S1braPL2dvfwRjV+9bbfqlGFqGa774laMXaGD95WnfWwU kOidwN+tVpkBP4u9cGhg3QloWlJA= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Q/NsQaV2Setb1hWoyertXchepEn7aGBQdtwUiO1NtyLvhlPblo1nkUenq+elzd OIzGdwfOkm5vkAa/aD2myTlvGjoXJD8i6T0MGB1PPDZRw/9lRidvd3Z2Mh9f1t0m lOihLUMgc1p3GcNRTgbakyrk7p4mlPB0Uw0TihRZaH018=; Received: (qmail 32241 invoked by alias); 30 Oct 2012 06:06:49 -0000 Received: (qmail 32217 invoked by uid 22791); 30 Oct 2012 06:06:47 -0000 X-SWARE-Spam-Status: No, hits=-3.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, TW_EG, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Oct 2012 06:06:41 +0000 Received: by mail-pa0-f47.google.com with SMTP id fa11so3738841pad.20 for ; Mon, 29 Oct 2012 23:06:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.66.87.133 with SMTP id ay5mr89653342pab.59.1351577200679; Mon, 29 Oct 2012 23:06:40 -0700 (PDT) Received: by 10.68.19.138 with HTTP; Mon, 29 Oct 2012 23:06:40 -0700 (PDT) In-Reply-To: References: <20121029130624.GA18506@gmail.com> <878vapjomq.fsf@talisman.home> Date: Mon, 29 Oct 2012 23:06:40 -0700 Message-ID: Subject: Re: PATCH: PR rtl-optimization/55093: [4.8 Regression] [x32] -maddress-mode=long failed From: "H.J. Lu" To: gcc-patches@gcc.gnu.org, Vladimir Makarov , rdsandiford@googlemail.com 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 On Mon, Oct 29, 2012 at 3:49 PM, H.J. Lu wrote: > On Mon, Oct 29, 2012 at 3:44 PM, H.J. Lu wrote: >> On Mon, Oct 29, 2012 at 8:15 AM, Richard Sandiford >> wrote: >>> "H.J. Lu" writes: >>>> Hi, >>>> >>>> This patch changes get_elimination to check register number instead of >>>> RTX. Tested on Linux/x32 with -maddress-mode=long. OK to install? >>> >>> FWIW, this doesn't sound right to me, at least not without more justification. >>> The idea is that things like frame_pointer_rtx are supposed to be unique, >>> so the original code: >>> >>>> if ((ep = elimination_map[hard_regno]) != NULL) >>>> - return ep->from_rtx != reg ? NULL : ep; >>>> from != hard_regno ? NULL : ep; >>> >>> ought to be correct in itself. reload did the same thing: >>> >>> for (ep = reg_eliminate; ep < ®_eliminate[NUM_ELIMINABLE_REGS]; >>> ep++) >>> if (ep->from_rtx == x && ep->can_eliminate) >>> return plus_constant (Pmode, ep->to_rtx, ep->previous_offset); >>> >>> It sounds on the face of it like the bug is elsewhere. >>> >> >> LRA has >> >> if (REG_P (reg) && (ep = get_elimination (reg)) != NULL) >> { >> rtx to_rtx = replace_p ? ep->to_rtx : ep->from_rtx; >> >> if (! replace_p) >> { >> offset += (ep->offset - ep->previous_offset); >> offset = trunc_int_for_mode (offset, GET_MODE (plus_cst_src)); >> } >> >> if (GET_CODE (XEXP (plus_cst_src, 0)) == SUBREG) >> to_rtx = gen_lowpart (GET_MODE (XEXP (plus_cst_src, 0)), to_rtx); >> >> Reload has >> >> rtx to_rtx = ep->to_rtx; >> offset += ep->offset; >> offset = trunc_int_for_mode (offset, GET_MODE (plus_cst_src)); >> >> if (GET_CODE (XEXP (plus_cst_src, 0)) == SUBREG) >> to_rtx = gen_lowpart (GET_MODE (XEXP (plus_cst_src, 0)), >> to_rtx); >> >> (gdb) call debug_rtx (ep->to_rtx) >> (reg/f:DI 7 sp) >> (gdb) call debug_rtx (ep->from_rtx) >> (reg/f:DI 16 argp) >> (gdb) >> >> gen_lowpart returns (reg/f:DI 7 sp) for reload and (reg:SI 16 argp) >> for LRA. They are caused by >> >> if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM >> /* We should convert arg register in LRA after the elimination >> if it is possible. */ >> && xregno == ARG_POINTER_REGNUM >> && ! lra_in_progress) >> return -1; >> >> It doesn't work in this case. >> > > This testcase shows that LRA can't convert arg register after > the elimination. > Here is a patch to remove ra_in_progress check for ARG_POINTER_REGNUM. Tested on Linux.x86-64. OK to install? Thanks. diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 43d4cb8..c1a7580 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -3494,10 +3494,7 @@ simplify_subreg_regno (unsigned int xregno, enum machine_mode xmode, return -1; if (FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM - /* We should convert arg register in LRA after the elimination - if it is possible. */ - && xregno == ARG_POINTER_REGNUM - && ! lra_in_progress) + && xregno == ARG_POINTER_REGNUM) return -1; if (xregno == STACK_POINTER_REGNUM diff --git a/gcc/testsuite/gcc.target/i386/pr55093.c b/gcc/testsuite/gcc.target/i386/pr55093.c new file mode 100644 index 0000000..76b4042 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr55093.c @@ -0,0 +1,80 @@ +/* { dg-do compile { target { ! { ia32 } } } } */ +/* { dg-options "-O2 -mx32 -maddress-mode=long" } */ + +typedef union tree_node *tree; +typedef const union tree_node *const_tree; +typedef struct { + unsigned long long low; + long long high; +} double_int; +struct real_value { +}; +struct real_format { + int has_signed_zero; +}; +extern const struct real_format * real_format_for_mode[]; +extern int real_isnegzero (const struct real_value *); +enum tree_code { REAL_CST, SSA_NAME }; +struct tree_base { + enum tree_code code : 16; + union { + unsigned int version; + } + u; +}; +extern void tree_check_failed (const_tree, const char *, int, const char *, ...) __attribute__ ((__noreturn__)); +union tree_node { + struct tree_base base; +}; +inline tree tree_check (tree __t, const char *__f, int __l, const char *__g, enum tree_code __c) { + if (((enum tree_code) (__t)->base.code) != __c) + tree_check_failed (__t, __f, __l, __g, __c, 0); + return __t; +} +struct prop_value_d { + int lattice_val; + tree value; + double_int mask; +}; +typedef struct prop_value_d prop_value_t; +static prop_value_t *const_val; +static void canonicalize_float_value (prop_value_t *); +typedef void (*ssa_prop_visit_stmt_fn) (prop_value_t); +typedef void (*ssa_prop_visit_phi_fn) (void); +typedef void (*ssa_prop_fold_stmt_fn) (void *gsi); +typedef void (*ssa_prop_get_value_fn) ( prop_value_t *val); +void ssa_propagate (ssa_prop_visit_stmt_fn, ssa_prop_visit_phi_fn); +int substitute_and_fold (ssa_prop_get_value_fn, ssa_prop_fold_stmt_fn); +void ccp_fold_stmt (void *); +static void get_constant_value (prop_value_t *val) { + canonicalize_float_value (val); +} +static void canonicalize_float_value (prop_value_t *val) { + int mode; + struct real_value d; + if (val->lattice_val != 1 + || ((enum tree_code) (val->value)->base.code) != REAL_CST) + return; + mode = val->lattice_val; + if (real_format_for_mode[mode]->has_signed_zero && real_isnegzero (&d)) + ccp_fold_stmt (0); +} +static void set_lattice_value (tree var, prop_value_t new_val) { + prop_value_t *old_val = &const_val[(tree_check ((var), "", + 0, "", + (SSA_NAME)))->base.u.version]; + canonicalize_float_value (&new_val); + canonicalize_float_value (old_val); +} +static void ccp_visit_phi_node (void) { + prop_value_t new_val; + set_lattice_value (0, new_val); +} +static void ccp_visit_stmt (prop_value_t v) { + set_lattice_value (0, v); +} +unsigned int do_ssa_ccp (void) { + ssa_propagate (ccp_visit_stmt, ccp_visit_phi_node); + substitute_and_fold (get_constant_value, ccp_fold_stmt);