From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 7C6DB3858D1E; Tue, 25 Apr 2023 15:39:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C6DB3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682437190; bh=qtmEMJJIBglZhui02+UnLUwr4IltH0TOF6ykXWIeqFM=; h=From:To:Subject:Date:From; b=iSl3bNR99Bi16/TmifS1DYGQW9vg/31LsOoDsUllqiWSPq9ezxFXbtrWRFjZMPdom KRXbFSczq7Z3tY+20xoMdD0fXw9N7S1weUspS5guaqZFg/fjFDKbRNDlqq94688VME bm09Z37nmRbXIlcowH5H0B+OE+tjP7fF8wm5fFGI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-226] Avoid creating useless debug temporaries X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: e8d00353017f895d03a9eabae3506fd126ce1a2d X-Git-Newrev: e262cdf49c52d2c6d6aedb30e9ce67e68a9f62a9 Message-Id: <20230425153950.7C6DB3858D1E@sourceware.org> Date: Tue, 25 Apr 2023 15:39:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e262cdf49c52d2c6d6aedb30e9ce67e68a9f62a9 commit r14-226-ge262cdf49c52d2c6d6aedb30e9ce67e68a9f62a9 Author: Eric Botcazou Date: Tue Apr 25 17:38:31 2023 +0200 Avoid creating useless debug temporaries insert_debug_temp_for_var_def has some strange code whereby it creates debug temporaries for SINGLE_RHS (RHS for gimple_assign_single_p) but not for other RHS in the same situation. gcc/ * tree-ssa.cc (insert_debug_temp_for_var_def): Do not create superfluous debug temporaries for single GIMPLE assignments. Diff: --- gcc/tree-ssa.cc | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/gcc/tree-ssa.cc b/gcc/tree-ssa.cc index a5cad2d344e..4ca1f5f3104 100644 --- a/gcc/tree-ssa.cc +++ b/gcc/tree-ssa.cc @@ -412,8 +412,7 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var) { /* If there's a single use of VAR, and VAR is the entire debug expression (usecount would have been incremented again - otherwise), and the definition involves only constants and - SSA names, then we can propagate VALUE into this single use, + otherwise), then we can propagate VALUE into this single use, avoiding the temp. We can also avoid using a temp if VALUE can be shared and @@ -424,11 +423,9 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var) are deferred to a debug temp, although we could avoid temps at the expense of duplication of expressions. */ - if (CONSTANT_CLASS_P (value) + if (usecount == 1 || gimple_code (def_stmt) == GIMPLE_PHI - || (usecount == 1 - && (!gimple_assign_single_p (def_stmt) - || is_gimple_min_invariant (value))) + || CONSTANT_CLASS_P (value) || is_gimple_reg (value)) ; else @@ -466,11 +463,6 @@ insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var) if (value) { FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter) - /* unshare_expr is not needed here. vexpr is either a - SINGLE_RHS, that can be safely shared, some other RHS - that was unshared when we found it had a single debug - use, or a DEBUG_EXPR_DECL, that can be safely - shared. */ SET_USE (use_p, unshare_expr (value)); /* If we didn't replace uses with a debug decl fold the resulting expression. Otherwise we end up with invalid IL. */