From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3625 invoked by alias); 12 Apr 2011 10:55:38 -0000 Received: (qmail 3616 invoked by uid 22791); 12 Apr 2011 10:55:37 -0000 X-SWARE-Spam-Status: No, hits=-6.4 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, 12 Apr 2011 10:55:27 +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 p3CAtD6m009405 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 12 Apr 2011 06:55:13 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p3CAtC7F007536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 Apr 2011 06:55:13 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p3CAtCfG008673; Tue, 12 Apr 2011 12:55:12 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p3CAtBxZ008671; Tue, 12 Apr 2011 12:55:11 +0200 Date: Tue, 12 Apr 2011 10:55:00 -0000 From: Jakub Jelinek To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix combiner ICEs after my recent patch (PR rtl-optimization/48549) Message-ID: <20110412105511.GD17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <20110411104958.GY17079@tyan-ft48-01.lab.bos.redhat.com> <201104120918.01366.ebotcazou@adacore.com> <20110412080647.GC17079@tyan-ft48-01.lab.bos.redhat.com> <201104121029.57672.ebotcazou@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201104121029.57672.ebotcazou@adacore.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg00853.txt.bz2 On Tue, Apr 12, 2011 at 10:29:57AM +0200, Eric Botcazou wrote: > > 2011-04-12 Jakub Jelinek > > > > PR rtl-optimization/48549 > > * combine.c (propagate_for_debug): Also stop after BB_END of > > this_basic_block. Process LAST and just stop processing after it. > > (combine_instructions): If last_combined_insn has been deleted, > > set last_combined_insn to its PREV_INSN. > > > > * g++.dg/opt/pr48549.C: New test. > > So OK modulo the last point, thanks. Thanks, here is what I've committed after bootstrap/regtest on x86_64-linux and i686-linux. Will now regtest it on 4.6 branch too, then test the extra JUMP_P patch + gcc_assert (at_end); just for trunk. 2011-04-12 Jakub Jelinek PR rtl-optimization/48549 * combine.c (propagate_for_debug): Also stop after BB_END of this_basic_block. Process LAST and just stop processing after it. (combine_instructions): If last_combined_insn has been deleted, set last_combined_insn to its PREV_INSN. * g++.dg/opt/pr48549.C: New test. --- gcc/combine.c.jj 2011-04-11 19:26:52.067577164 +0200 +++ gcc/combine.c 2011-04-12 10:40:12.592795949 +0200 @@ -1198,8 +1198,13 @@ combine_instructions (rtx f, unsigned in next = 0; if (NONDEBUG_INSN_P (insn)) { + while (last_combined_insn + && INSN_DELETED_P (last_combined_insn)) + last_combined_insn = PREV_INSN (last_combined_insn); if (last_combined_insn == NULL_RTX - || DF_INSN_LUID (last_combined_insn) < DF_INSN_LUID (insn)) + || BARRIER_P (last_combined_insn) + || BLOCK_FOR_INSN (last_combined_insn) != this_basic_block + || DF_INSN_LUID (last_combined_insn) <= DF_INSN_LUID (insn)) last_combined_insn = insn; /* See if we know about function return values before this @@ -2446,19 +2451,21 @@ propagate_for_debug_subst (rtx from, con } /* Replace all the occurrences of DEST with SRC in DEBUG_INSNs between INSN - and LAST. */ + and LAST, not including INSN, but including LAST. Also stop at the end + of THIS_BASIC_BLOCK. */ static void propagate_for_debug (rtx insn, rtx last, rtx dest, rtx src) { - rtx next, loc; + rtx next, loc, end = NEXT_INSN (BB_END (this_basic_block)); struct rtx_subst_pair p; p.to = src; p.adjusted = false; next = NEXT_INSN (insn); - while (next != last) + last = NEXT_INSN (last); + while (next != last && next != end) { insn = next; next = NEXT_INSN (insn); --- gcc/testsuite/g++.dg/opt/pr48549.C.jj 2011-04-12 10:36:23.720513425 +0200 +++ gcc/testsuite/g++.dg/opt/pr48549.C 2011-04-12 10:36:23.720513425 +0200 @@ -0,0 +1,63 @@ +// PR rtl-optimization/48549 +// { dg-do compile } +// { dg-options "-fcompare-debug -O2" } + +void +foo (void *from, void *to) +{ + long offset = reinterpret_cast (to) - reinterpret_cast (from); + if (offset != static_cast (offset)) + *(int *) 0xC0DE = 0; + reinterpret_cast (from)[1] = offset; +} +struct A +{ + A () : a () {} + A (void *x) : a (x) {} + void *bar () { return a; } + void *a; +}; +struct C; +struct D; +struct E : public A +{ + C m1 (int); + D m2 (); + E () {} + E (A x) : A (x) {} +}; +struct C : public E +{ + C () {} + C (void *x) : E (x) {} +}; +struct D : public E +{ + D (void *x) : E (x) {} +}; +C +E::m1 (int x) +{ + return (reinterpret_cast (bar ()) + x); +} +D +E::m2 () +{ + return reinterpret_cast (bar ()); +} +struct B +{ + E a; + unsigned b : 16; + unsigned c : 1; +}; +void +baz (B *x) +{ + for (unsigned i = 0; i < 64; i++) + { + D d = x[i].a.m2 (); + C c = x[i].a.m1 (x[i].c); + foo (d.bar (), c.bar ()); + } +} Jakub