From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1011) id 2DCA83858C2B; Fri, 15 Sep 2023 14:13:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DCA83858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694787221; bh=4K05daOuAYU4fZg4DDVwWf8ecWYpe6Gk7HlY/25P+wQ=; h=From:To:Subject:Date:From; b=AICECWxSx/zkOlTctiqNyDB8Fkwguo6MRa98PS7tu5palgBuur0IDKoUk8pJszMd+ vpcWio8e25PR7pv8OONDerxknnWTLizXcTDYQfkKPlrQOov1NFzdq1IRihB8z9yD17 Ew0Ms/UP4s8vORO8rwdUxPi6V+lteTcSVVc/pD/s= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Macleod To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-4036] Always do PHI analysis and before loop analysis. X-Act-Checkin: gcc X-Git-Author: Andrew MacLeod X-Git-Refname: refs/heads/master X-Git-Oldrev: c43bd879b46c46b218c1040d68d0c7810cb47039 X-Git-Newrev: 76a2d567842088ff296609c9e3b53c3df179aefd Message-Id: <20230915141341.2DCA83858C2B@sourceware.org> Date: Fri, 15 Sep 2023 14:13:41 +0000 (GMT) List-Id: https://gcc.gnu.org/g:76a2d567842088ff296609c9e3b53c3df179aefd commit r14-4036-g76a2d567842088ff296609c9e3b53c3df179aefd Author: Andrew MacLeod Date: Wed Sep 13 10:09:16 2023 -0400 Always do PHI analysis and before loop analysis. PHI analysis wasn't being done if loop analysis found a value. Always do the PHI analysis, and run it for an iniital value before invoking loop analysis. * gimple-range-fold.cc (fold_using_range::range_of_phi): Always run phi analysis, and do it before loop analysis. Diff: --- gcc/gimple-range-fold.cc | 53 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 03805d88d9b..d1945ccb554 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -939,7 +939,32 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src) } } - bool loop_info_p = false; + // If PHI analysis is available, see if there is an iniital range. + if (phi_analysis_available_p () + && irange::supports_p (TREE_TYPE (phi_def))) + { + phi_group *g = (phi_analysis())[phi_def]; + if (g && !(g->range ().varying_p ())) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "PHI GROUP query for "); + print_generic_expr (dump_file, phi_def, TDF_SLIM); + fprintf (dump_file, " found : "); + g->range ().dump (dump_file); + fprintf (dump_file, " and adjusted original range from :"); + r.dump (dump_file); + } + r.intersect (g->range ()); + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, " to :"); + r.dump (dump_file); + fprintf (dump_file, "\n"); + } + } + } + // If SCEV is available, query if this PHI has any known values. if (scev_initialized_p () && !POINTER_TYPE_P (TREE_TYPE (phi_def))) @@ -962,32 +987,6 @@ fold_using_range::range_of_phi (vrange &r, gphi *phi, fur_source &src) fprintf (dump_file, "\n"); } r.intersect (loop_range); - loop_info_p = true; - } - } - } - - if (!loop_info_p && phi_analysis_available_p () - && irange::supports_p (TREE_TYPE (phi_def))) - { - phi_group *g = (phi_analysis())[phi_def]; - if (g && !(g->range ().varying_p ())) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "PHI GROUP query for "); - print_generic_expr (dump_file, phi_def, TDF_SLIM); - fprintf (dump_file, " found : "); - g->range ().dump (dump_file); - fprintf (dump_file, " and adjusted original range from :"); - r.dump (dump_file); - } - r.intersect (g->range ()); - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, " to :"); - r.dump (dump_file); - fprintf (dump_file, "\n"); } } }