From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28289 invoked by alias); 4 Jul 2012 09:55:43 -0000 Received: (qmail 28275 invoked by uid 22791); 4 Jul 2012 09:55:41 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED,TW_TM X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Jul 2012 09:55:29 +0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/53844] [4.6/4.7 Regression] GCC generates suboptimal code for unused members of classes in some cases on multiple targets. Date: Wed, 04 Jul 2012 09:55:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.6.4 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-07/txt/msg00428.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53844 --- Comment #5 from Richard Guenther 2012-07-04 09:55:27 UTC --- For trunk dse_possible_dead_store_p fails to look through the loop, when being at the VDEF .MEM_165: : # i_93 = PHI # .MEM_100 = PHI <.MEM_165(3), .MEM_68(2)> # VUSE <.MEM_100> D.3879_71 = MEM[(struct VBase *)out_2(D)].my_data; D.3880_73 = (long unsigned int) i_93; D.3881_74 = D.3880_73 * 8; D.3878_75 = D.3879_71 + D.3881_74; # VUSE <.MEM_100> D.3975_138 = MEM[(const struct VBase *)in_1(D)].my_data; D.3974_141 = D.3975_138 + D.3881_74; # VUSE <.MEM_100> D.3981_142 = *D.3974_141; # .MEM_165 = VDEF <.MEM_100> *D.3878_75 = D.3981_142; i_78 = i_93 + 1; if (i_78 != 100) goto ; else goto ; : # .MEM_28 = VDEF <.MEM_165> D.2811 ={v} {CLOBBER}; we then see two uses that have a VDEF - the PHI (which we processed before), and the store after the loop. The following fixes that Index: gcc/tree-ssa-dse.c =================================================================== --- gcc/tree-ssa-dse.c (revision 189248) +++ gcc/tree-ssa-dse.c (working copy) @@ -94,7 +94,7 @@ dse_possible_dead_store_p (gimple stmt, temp = stmt; do { - gimple use_stmt; + gimple use_stmt, defvar_def; imm_use_iterator ui; bool fail = false; tree defvar; @@ -108,6 +108,7 @@ dse_possible_dead_store_p (gimple stmt, defvar = PHI_RESULT (temp); else defvar = gimple_vdef (temp); + defvar_def = temp; temp = NULL; FOR_EACH_IMM_USE_STMT (use_stmt, ui, defvar) { @@ -139,7 +140,13 @@ dse_possible_dead_store_p (gimple stmt, fail = true; BREAK_FROM_IMM_USE_STMT (ui); } - temp = use_stmt; + /* Do not consider the PHI as use if it dominates the + stmt defining the virtual operand we are processing. */ + if (gimple_bb (defvar_def) != gimple_bb (use_stmt) + && !dominated_by_p (CDI_DOMINATORS, + gimple_bb (defvar_def), + gimple_bb (use_stmt))) + temp = use_stmt; } /* If the statement is a use the store is not dead. */ else if (ref_maybe_used_by_stmt_p (use_stmt, but the existing loop code is weird ... I'm anyway testing the above.