From patchwork Mon Jan 23 15:58:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramana Radhakrishnan X-Patchwork-Id: 6348 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E136B23ECC for ; Mon, 23 Jan 2012 15:58:37 +0000 (UTC) Received: from mail-bk0-f52.google.com (mail-bk0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id A89C7A18011 for ; Mon, 23 Jan 2012 15:58:37 +0000 (UTC) Received: by bkar19 with SMTP id r19so2900350bka.11 for ; Mon, 23 Jan 2012 07:58:37 -0800 (PST) Received: by 10.205.120.17 with SMTP id fw17mr3357238bkc.74.1327334317357; Mon, 23 Jan 2012 07:58:37 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.204.130.220 with SMTP id u28cs75974bks; Mon, 23 Jan 2012 07:58:36 -0800 (PST) Received: by 10.224.116.211 with SMTP id n19mr9813086qaq.67.1327334314865; Mon, 23 Jan 2012 07:58:34 -0800 (PST) Received: from mail-tul01m020-f178.google.com (mail-tul01m020-f178.google.com [209.85.214.178]) by mx.google.com with ESMTPS id p1si9640603qad.67.2012.01.23.07.58.34 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 Jan 2012 07:58:34 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of ramana.radhakrishnan@linaro.org) client-ip=209.85.214.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.178 is neither permitted nor denied by best guess record for domain of ramana.radhakrishnan@linaro.org) smtp.mail=ramana.radhakrishnan@linaro.org Received: by obbwc7 with SMTP id wc7so4372848obb.37 for ; Mon, 23 Jan 2012 07:58:34 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.5.227 with SMTP id v3mr5867950obv.33.1327334314040; Mon, 23 Jan 2012 07:58:34 -0800 (PST) Received: by 10.182.88.7 with HTTP; Mon, 23 Jan 2012 07:58:33 -0800 (PST) In-Reply-To: <201201231002.00428.ebotcazou@adacore.com> References: <201201221153.32801.ebotcazou@adacore.com> <201201231002.00428.ebotcazou@adacore.com> Date: Mon, 23 Jan 2012 15:58:33 +0000 Message-ID: Subject: Re: [RFC combine] PR48308 - Fix issue with missing(?) LOG_LINKS From: Ramana Radhakrishnan To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org, Patch Tracking X-Gm-Message-State: ALoCoQk5qxTpcjdDQAjclTLKX02IpfFvVCbwyUElsOdhYbb+gtxcD+yOWJX833NIKDePbB4lN7Qf On 23 January 2012 09:02, Eric Botcazou wrote: >> Do you mean something like this instead ? I'm testing this - Ok if no >> regressions ? > > OK with an appropriate ChangeLog. Or not :( We really shouldn't use SUBST there as it only deals with rtx * It appeared better to invent a new SUBST for links given that the type of this expression is struct insn_link rather than rtx * (Doh !) I did think about hacking up a local flag but somehow like this version better. It's survived a bootstrap and testrun with no regressions for c,c++,fortran,ada on one of the power7 machines for powerpc64-unknown-linux-gnu in the compile farm. I'll put it through it's paces for trunk (arm-linux-gnueabi / x86_64) and 4.6 (modulo API changes for alloc_insn_link) if you think this looks better. cheers Ramana 2012-01-23 Ramana Radhakrishnan PR rtl-optimization/48308 * combine.c (do_SUBST_LINK): Declare and define. (SUBST_LINK): New. (try_combine): Handle LOG_LINKS for dummy i1 case. > > -- > Eric Botcazou Index: gcc/combine.c =================================================================== --- gcc/combine.c (revision 183416) +++ gcc/combine.c (working copy) @@ -367,14 +367,14 @@ /* Record one modification to rtl structure to be undone by storing old_contents into *where. */ -enum undo_kind { UNDO_RTX, UNDO_INT, UNDO_MODE }; +enum undo_kind { UNDO_RTX, UNDO_INT, UNDO_MODE, UNDO_LINKS }; struct undo { struct undo *next; enum undo_kind kind; - union { rtx r; int i; enum machine_mode m; } old_contents; - union { rtx *r; int *i; } where; + union { rtx r; int i; enum machine_mode m; struct insn_link *l; } old_contents; + union { rtx *r; int *i; struct insn_link **l; } where; }; /* Record a bunch of changes to be undone, up to MAX_UNDO of them. @@ -698,7 +698,8 @@ that are perfectly valid, so we'd waste too much effort for little gain doing the checks here. Focus on catching invalid transformations involving integer constants. */ - if (GET_MODE_CLASS (GET_MODE (oldval)) == MODE_INT + if (oldval + && GET_MODE_CLASS (GET_MODE (oldval)) == MODE_INT && CONST_INT_P (newval)) { /* Sanity check that we're replacing oldval with a CONST_INT @@ -789,6 +790,33 @@ } #define SUBST_MODE(INTO, NEWVAL) do_SUBST_MODE(&(INTO), (NEWVAL)) + +/* Similar to SUBST, but NEWVAL is a LOG_LINKS expression. */ + +static void +do_SUBST_LINK (struct insn_link **into, struct insn_link *newval) +{ + struct undo *buf; + struct insn_link * oldval = *into; + + if (oldval == newval) + return; + + if (undobuf.frees) + buf = undobuf.frees, undobuf.frees = buf->next; + else + buf = XNEW (struct undo); + + buf->kind = UNDO_LINKS; + buf->where.l = into; + buf->old_contents.l = oldval; + *into = newval; + + buf->next = undobuf.undos, undobuf.undos = buf; +} + +#define SUBST_LINK(oldval, newval) do_SUBST_LINK (&oldval, newval) + /* Subroutine of try_combine. Determine whether the replacement patterns NEWPAT, NEWI2PAT and NEWOTHERPAT are cheaper according to insn_rtx_cost @@ -2865,6 +2893,7 @@ SUBST (PATTERN (i2), XVECEXP (PATTERN (i2), 0, 0)); SUBST (XEXP (SET_SRC (PATTERN (i2)), 0), SET_DEST (PATTERN (i1))); + SUBST_LINK (LOG_LINKS (i2), alloc_insn_link (i1, LOG_LINKS (i2))); } } #endif @@ -4494,6 +4523,9 @@ case UNDO_MODE: adjust_reg_mode (*undo->where.r, undo->old_contents.m); break; + case UNDO_LINKS: + *undo->where.l = undo->old_contents.l; + break; default: gcc_unreachable (); }