From patchwork Mon Dec 19 14:09:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 132234 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 8E420B6FF0 for ; Tue, 20 Dec 2011 01:09:40 +1100 (EST) Received: (qmail 20220 invoked by alias); 19 Dec 2011 14:09:38 -0000 Received: (qmail 20209 invoked by uid 22791); 19 Dec 2011 14:09:37 -0000 X-SWARE-Spam-Status: No, hits=-5.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_CF, TW_TM 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; Mon, 19 Dec 2011 14:09:18 +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.14.4/8.14.4) with ESMTP id pBJE9IFr003217 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Dec 2011 09:09:18 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBJE9HK5008124 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 19 Dec 2011 09:09:18 -0500 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id pBJE9Hp9014605; Mon, 19 Dec 2011 15:09:17 +0100 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id pBJE9HBu014603; Mon, 19 Dec 2011 15:09:17 +0100 Date: Mon, 19 Dec 2011 15:09:17 +0100 From: Jakub Jelinek To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Call gimple_purge_dead_eh_edges in replace_uses_by if needed (PR tree-optimization/51596) Message-ID: <20111219140916.GG1957@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi! We were ignoring maybe_clean_or_replace_eh_stmt return value, which tells us if stmt previously could throw but doesn't any longer. I was a little bit worried that gimple_purge_dead_eh_edges from within cfg cleanup wouldn't work well, but at least bootstrap/regtested on x86_64-linux and i686-linux didn't show any issues. Ok for trunk? 2011-12-19 Jakub Jelinek PR tree-optimization/51596 * tree-cfg.c (replace_uses_by): Call gimple_purge_dead_eh_edges when needed. * g++.dg/opt/pr51596.C: New test. Jakub --- gcc/tree-cfg.c.jj 2011-12-16 17:34:07.000000000 +0100 +++ gcc/tree-cfg.c 2011-12-19 11:47:12.554921183 +0100 @@ -1627,7 +1627,8 @@ replace_uses_by (tree name, tree val) if (fold_stmt (&gsi)) stmt = gsi_stmt (gsi); - maybe_clean_or_replace_eh_stmt (orig_stmt, stmt); + if (maybe_clean_or_replace_eh_stmt (orig_stmt, stmt)) + gimple_purge_dead_eh_edges (gimple_bb (stmt)); update_stmt (stmt); } --- gcc/testsuite/g++.dg/opt/pr51596.C.jj 2011-12-19 11:49:43.548046185 +0100 +++ gcc/testsuite/g++.dg/opt/pr51596.C 2011-12-19 11:48:49.000000000 +0100 @@ -0,0 +1,39 @@ +// PR tree-optimization/51596 +// { dg-do compile } +// { dg-options "-O -fnon-call-exceptions" } + +struct A { float v[2]; }; +struct B { int v[2]; }; + +struct C +{ + B c; + C f () + { + B b; + for (int i = 0; i < 2; i++) + b.v[i] = c.v[i]; + return *this; + } +}; + +struct D +{ + A d; + D (B x) + { + for (int i = 0; i < 2; i++) + d.v[i] = x.v[i]; + } +}; + +int bar (); + +C i; + +void +foo () +{ + while (bar ()) + D (i.f ().c); +}