From patchwork Thu Jan 27 20:04:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 80729 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 E7EF0B711C for ; Fri, 28 Jan 2011 07:04:47 +1100 (EST) Received: (qmail 15276 invoked by alias); 27 Jan 2011 20:04:46 -0000 Received: (qmail 15267 invoked by uid 22791); 27 Jan 2011 20:04:45 -0000 X-SWARE-Spam-Status: No, hits=-6.1 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; Thu, 27 Jan 2011 20:04:41 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0RK4d6q014423 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 27 Jan 2011 15:04:39 -0500 Received: from greed.delorie.com (ovpn-112-32.phx2.redhat.com [10.3.112.32]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p0RK4bkI020700 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 27 Jan 2011 15:04:39 -0500 Received: from greed.delorie.com (localhost.localdomain [127.0.0.1]) by greed.delorie.com (8.14.4/8.14.4) with ESMTP id p0RK4aMe017953 for ; Thu, 27 Jan 2011 15:04:37 -0500 Received: (from dj@localhost) by greed.delorie.com (8.14.4/8.14.4/Submit) id p0RK4aO6017952; Thu, 27 Jan 2011 15:04:36 -0500 Date: Thu, 27 Jan 2011 15:04:36 -0500 Message-Id: <201101272004.p0RK4aO6017952@greed.delorie.com> From: DJ Delorie To: gcc-patches@gcc.gnu.org Subject: PR rtl-optimization/46878 fix 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 Approved in the PR. Committed. 2011-01-26 DJ Delorie PR rtl-optimization/46878 * combine.c (insn_a_feeds_b): Check for the implicit cc0 setter/user dependency as well. 2011-01-26 DJ Delorie PR rtl-optimization/46878 * gcc.dg/pr46878-1.c: New test. Index: combine.c =================================================================== --- combine.c (revision 169299) +++ combine.c (working copy) @@ -1029,21 +1029,27 @@ clear_log_links (void) free_INSN_LIST_list (&LOG_LINKS (insn)); } /* Walk the LOG_LINKS of insn B to see if we find a reference to A. Return true if we found a LOG_LINK that proves that A feeds B. This only works if there are no instructions between A and B which could have a link - depending on A, since in that case we would not record a link for B. */ + depending on A, since in that case we would not record a link for B. + We also check the implicit dependency created by a cc0 setter/user + pair. */ static bool insn_a_feeds_b (rtx a, rtx b) { rtx links; for (links = LOG_LINKS (b); links; links = XEXP (links, 1)) if (XEXP (links, 0) == a) return true; +#ifdef HAVE_cc0 + if (sets_cc0_p (a)) + return true; +#endif return false; } /* Main entry point for combiner. F is the first insn of the function. NREGS is the first unused pseudo-reg number. Index: testsuite/gcc.dg/pr46878-1.c =================================================================== --- testsuite/gcc.dg/pr46878-1.c (revision 0) +++ testsuite/gcc.dg/pr46878-1.c (revision 0) @@ -0,0 +1,30 @@ +/* PR rtl-optimization/46878 */ +/* Make sure this doesn't ICE. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +struct baz +{ + int *newp; +}; + +int +get_ice (int *op, struct baz *ret) +{ + int *tmpp; + int c; + c = (__foo () != 1); + if (__bar ()) + { + return (1); + } + if (c) + tmpp = op; + if (tmpp) + { + } + else if (c) + { + ret->newp = tmpp; + } +}