From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 41D82384F030; Fri, 23 Dec 2022 15:22:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41D82384F030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671808931; bh=H9RmssXgwI2h2GJMkmFKmX/gcCVAEaI4qy1E1BWBNaU=; h=From:To:Subject:Date:From; b=U5KbXV6NkHMWCJfg5aivN+QUtdSq+SMZk6JO+p2EG/XIVgf8Jiav4cWnwrA5rRmIR KoH7xh3uA8fUDD4nn8NiyGh8KuAL4vIKXMCUxU5p0wxDax3N3vjqqVbORO2g6bEPSe t2zIS2dKaoeu51rCK9ODyyDfwdNaRCkXWs+173gc= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4878] phiopt: Improve value_replacement maybe equal phires range handling X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: fd1b0aefda5b65f3f841ca6e61ccea6a72daa060 X-Git-Newrev: 3d6bb832022160b00e7001ac5b467e201ab4a9ac Message-Id: <20221223152211.41D82384F030@sourceware.org> Date: Fri, 23 Dec 2022 15:22:11 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3d6bb832022160b00e7001ac5b467e201ab4a9ac commit r13-4878-g3d6bb832022160b00e7001ac5b467e201ab4a9ac Author: Jakub Jelinek Date: Fri Dec 23 16:19:08 2022 +0100 phiopt: Improve value_replacement maybe equal phires range handling My previous patch added throwing away of SSA_NAME_RANGE_INFO of phires when we have phires = x != carg ? x : oarg, but that could throw away useful range info, all we need is merge phires current range info with the carg constant which can newly appear there (and the optimization proved the single user doesn't care about that). 2022-12-23 Jakub Jelinek Aldy Hernandez * tree-ssa-phiopt.cc (value_replacement): Instead of resetting phires range info, union it with carg. Diff: --- gcc/tree-ssa-phiopt.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 906b406970f..59dc21cee50 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -1492,11 +1492,25 @@ value_replacement (basic_block cond_bb, basic_block middle_bb, break; } if (equal_p) - /* After the optimization PHI result can have value - which it couldn't have previously. - We could instead of resetting it union the range - info with oarg. */ - reset_flow_sensitive_info (gimple_phi_result (phi)); + { + tree phires = gimple_phi_result (phi); + if (SSA_NAME_RANGE_INFO (phires)) + { + /* After the optimization PHI result can have value + which it couldn't have previously. */ + int_range_max r; + if (get_global_range_query ()->range_of_expr (r, phires, + phi)) + { + int_range<2> tmp (carg, carg); + r.union_ (tmp); + reset_flow_sensitive_info (phires); + set_range_info (phires, r); + } + else + reset_flow_sensitive_info (phires); + } + } if (equal_p && MAY_HAVE_DEBUG_BIND_STMTS) { imm_use_iterator imm_iter;