From patchwork Wed Oct 31 03:13:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 195723 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 24D992C007F for ; Wed, 31 Oct 2012 14:13:55 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352258036; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:Received:From:To:Cc:Subject:References:Date: In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=Ee2NLY61ofgrx3yR2hV3 1L5n2pY=; b=eMdoqRNdrwXqeb25NpO0l4rkHyp5kjEDwV7gfnERV5s+VFRCrHYs 5+C+6b+apQ9o7V0oOMMPiWv5ZOgNK833N833te2FKEsE9lU+RyBRiiigZLmVWyzB Z8jPStpin25NgGywhnx7+hPCxWPgB2KhJvwHkm4/q2TGxW55VekVGlc= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:Received:From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=JxqKLW4I/dgVyJrssW7YlIdxyorRqSXsUe1czU3Wt5jvhHjXuizrERsnmJZNPm DiBKGx5sAwAbwkvBQ2/EpkH7JoDy69zM3ohzNIYXTfl7r/GTIkAV+2eKMKXIXCcb Z17e9dmGhkettj+luDKgvLe1kw7fqfZk78S4plAf7sYr0=; Received: (qmail 5974 invoked by alias); 31 Oct 2012 03:13:48 -0000 Received: (qmail 5965 invoked by uid 22791); 31 Oct 2012 03:13:46 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS, TW_TM, T_TVD_MIME_NO_HEADERS 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; Wed, 31 Oct 2012 03:13:33 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9V3DWBM021741 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 30 Oct 2012 23:13:32 -0400 Received: from freie (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q9V3DUUR019036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 30 Oct 2012 23:13:32 -0400 Received: from livre.localdomain (livre-to-gw.oliva.athome.lsd.ic.unicamp.br [172.31.160.19]) by freie (8.14.5/8.14.5) with ESMTP id q9V3DUhQ001690; Wed, 31 Oct 2012 01:13:30 -0200 Received: from livre.localdomain (aoliva@localhost.localdomain [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id q9V3DTBx001917; Wed, 31 Oct 2012 01:13:29 -0200 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id q9V3DSpT001913; Wed, 31 Oct 2012 01:13:28 -0200 From: Alexandre Oliva To: Jakub Jelinek Cc: Richard Biener , gcc-patches@gcc.gnu.org Subject: Re: [PR54693] loss of debug info in jump threading and loop ivopts References: <20121030151912.GT1752@tucnak.redhat.com> Date: Wed, 31 Oct 2012 01:13:28 -0200 In-Reply-To: (Alexandre Oliva's message of "Tue, 30 Oct 2012 21:03:57 -0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 On Oct 30, 2012, Alexandre Oliva wrote: >> BTW, I'd also think that the first loop should set count = 2 if >> the debug stmt already has a non-trivial expression > Good! Will do. Here's the revised patch. Bootstrap completed, test nearly finished. Ok to install if it passes? Replace PHI nodes of dropped ivs with debug temps From: Alexandre Oliva , Jakub Jelinek for gcc/ChangeLog PR debug/54693 * tree-ssa-loop-ivopts.c (remove_unused_ivs): Emit debug temps for dropped IV sets. --- gcc/tree-ssa-loop-ivopts.c | 106 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 105 insertions(+), 1 deletions(-) diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 9bca5e3..022adec 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -6422,7 +6422,111 @@ remove_unused_ivs (struct ivopts_data *data) && !info->inv_id && !info->iv->have_use_for && !info->preserve_biv) - bitmap_set_bit (toremove, SSA_NAME_VERSION (info->iv->ssa_name)); + { + bitmap_set_bit (toremove, SSA_NAME_VERSION (info->iv->ssa_name)); + + tree def = info->iv->ssa_name; + + if (MAY_HAVE_DEBUG_STMTS && SSA_NAME_DEF_STMT (def)) + { + imm_use_iterator imm_iter; + use_operand_p use_p; + gimple stmt; + int count = 0; + + FOR_EACH_IMM_USE_STMT (stmt, imm_iter, def) + { + if (!gimple_debug_bind_p (stmt)) + continue; + + /* We just want to determine whether to do nothing + (count == 0), to substitute the computed + expression into a single use of the SSA DEF by + itself (count == 1), or to use a debug temp + because the SSA DEF is used multiple times or as + part of a larger expression (count > 1). */ + count++; + if (gimple_debug_bind_get_value (stmt) != def) + count++; + + if (count > 1) + BREAK_FROM_IMM_USE_STMT (imm_iter); + } + + if (!count) + continue; + + struct iv_use dummy_use; + struct iv_cand *best_cand = NULL, *cand; + unsigned i, best_pref = 0, cand_pref; + + memset (&dummy_use, 0, sizeof (dummy_use)); + dummy_use.iv = info->iv; + for (i = 0; i < n_iv_uses (data) && i < 64; i++) + { + cand = iv_use (data, i)->selected; + if (cand == best_cand) + continue; + cand_pref = operand_equal_p (cand->iv->step, + info->iv->step, 0) + ? 4 : 0; + cand_pref + += TYPE_MODE (TREE_TYPE (cand->iv->base)) + == TYPE_MODE (TREE_TYPE (info->iv->base)) + ? 2 : 0; + cand_pref + += TREE_CODE (cand->iv->base) == INTEGER_CST + ? 1 : 0; + if (best_cand == NULL || best_pref < cand_pref) + { + best_cand = cand; + best_pref = cand_pref; + } + } + + if (!best_cand) + continue; + + tree comp = get_computation_at (data->current_loop, + &dummy_use, best_cand, + SSA_NAME_DEF_STMT (def)); + if (!comp) + continue; + + if (count > 1) + { + tree vexpr = make_node (DEBUG_EXPR_DECL); + DECL_ARTIFICIAL (vexpr) = 1; + TREE_TYPE (vexpr) = TREE_TYPE (comp); + if (SSA_NAME_VAR (def)) + DECL_MODE (vexpr) = DECL_MODE (SSA_NAME_VAR (def)); + else + DECL_MODE (vexpr) = TYPE_MODE (TREE_TYPE (vexpr)); + gimple def_temp = gimple_build_debug_bind (vexpr, comp, NULL); + gimple_stmt_iterator gsi; + + if (gimple_code (SSA_NAME_DEF_STMT (def)) == GIMPLE_PHI) + gsi = gsi_after_labels (gimple_bb + (SSA_NAME_DEF_STMT (def))); + else + gsi = gsi_for_stmt (SSA_NAME_DEF_STMT (def)); + + gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT); + comp = vexpr; + } + + FOR_EACH_IMM_USE_STMT (stmt, imm_iter, def) + { + if (!gimple_debug_bind_p (stmt)) + continue; + + FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) + SET_USE (use_p, comp); + + update_stmt (stmt); + } + } + } } release_defs_bitset (toremove);