From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id AA1033858D35; Tue, 7 Feb 2023 13:39:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA1033858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675777192; bh=UaJgIRR1CUPU6t18VpBU8fetpLi6MTKijl008cowIGY=; h=From:To:Subject:Date:From; b=D/frfCMfwN6l6GVn4alxNMZyAq4A/4pzUpwZ+lzbQ+1jZQX7s9Sy5GL8VE5QRJfq8 WolGAr7I60RELWl+bg/x+KuAzsrmwII7oAxf1gwdiAbuxuhZcj+vjIIAdQgkQHHwJy bZ1Ugb9LDfmFSgmlfZOQGZxIrZrsTlFcnpLuxbf0= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5729] tree-optimization/26854 - compile-time hog in SSA forwprop X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 5321d53279a60ee589a3c9779beb46503f9fc49f X-Git-Newrev: 295adfc9ed20468cdaba3afe258d57b58a8df792 Message-Id: <20230207133952.AA1033858D35@sourceware.org> Date: Tue, 7 Feb 2023 13:39:52 +0000 (GMT) List-Id: https://gcc.gnu.org/g:295adfc9ed20468cdaba3afe258d57b58a8df792 commit r13-5729-g295adfc9ed20468cdaba3afe258d57b58a8df792 Author: Richard Biener Date: Tue Feb 7 13:01:12 2023 +0100 tree-optimization/26854 - compile-time hog in SSA forwprop The following addresses tree forward propagate : 12.41 ( 9%) seen with the compile.i testcase of this PR which points at the has_use_on_stmt function which, for SSA names with many uses is slow. The solution is to instead of immediate uses, look at stmt operands to identify whether a name has a use on a stmt. That improves SSA forwprop to tree forward propagate : 1.30 ( 0%) for this testcase. PR tree-optimization/26854 * gimple-fold.cc (has_use_on_stmt): Look at stmt operands instead of immediate uses. Diff: --- gcc/gimple-fold.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index 379d2e930ea..935e8006413 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -5767,15 +5767,17 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace) } -/* Return true whether NAME has a use on STMT. */ +/* Return true whether NAME has a use on STMT. Note this can return + false even though there's a use on STMT if SSA operands are not + up-to-date. */ static bool has_use_on_stmt (tree name, gimple *stmt) { - imm_use_iterator iter; - use_operand_p use_p; - FOR_EACH_IMM_USE_FAST (use_p, iter, name) - if (USE_STMT (use_p) == stmt) + ssa_op_iter iter; + tree op; + FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE) + if (op == name) return true; return false; }