[gcc r17-3264] range: remove the abnormal-PHI restriction from gimple_range_ssa_p

Aldy Hernandez via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:6cda72b8bd646c32a691ae1424387da259f61edc

commit r17-3264-g6cda72b8bd646c32a691ae1424387da259f61edc
Author: Aldy Hernandez <[email protected]>
Date:   Thu Aug 13 07:00:26 2026 +0000

    range: remove the abnormal-PHI restriction from gimple_range_ssa_p
    
    The ranger has refused to look at SSA names occurring in abnormal
    PHIs since r12-4443-g93ac832f1846e4, but there is no reason range
    analysis cannot handle them.  The abnormal marker is a constraint on
    transformations, not on analysis: no copy can be inserted on an
    abnormal edge, so the incoming value and the PHI result must
    coalesce.  Analysis learns nothing from conditions on abnormal edges
    (there are none), but PHI and copy semantics hold like anywhere else.
    
    Tested on ppc64le Linux.
    
    gcc/ChangeLog:
    
            * gimple-range-fold.h (gimple_range_ssa_p): Remove the
            SSA_NAME_OCCURS_IN_ABNORMAL_PHI check.
            * gimple-range-path.cc (path_range_query::ssa_range_in_phi):
            Assert the incoming path edge is not abnormal.

Diff:
---
 gcc/gimple-range-fold.h  | 1 -
 gcc/gimple-range-path.cc | 4 ++++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-range-fold.h b/gcc/gimple-range-fold.h
index b11c179d173b..bf4310847e41 100644
--- a/gcc/gimple-range-fold.h
+++ b/gcc/gimple-range-fold.h
@@ -90,7 +90,6 @@ gimple_range_ssa_p (tree exp)
 {
   if (exp && TREE_CODE (exp) == SSA_NAME &&
       !SSA_NAME_IS_VIRTUAL_OPERAND (exp) &&
-      !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (exp) &&
       value_range::supports_type_p (TREE_TYPE (exp)))
     return exp;
   return NULL_TREE;
diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index 8a89da3dda37..467e321b8ded 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -256,6 +256,10 @@ path_range_query::ssa_range_in_phi (vrange &r, gphi *phi)
   basic_block bb = gimple_bb (phi);
   basic_block prev = prev_bb ();
   edge e_in = find_edge (prev, bb);
+  // The incoming edge the path supplies is never abnormal, so the
+  // argument on it is a valid value for the PHI result even when the
+  // result occurs in an abnormal PHI.
+  gcc_checking_assert (!(e_in->flags & EDGE_ABNORMAL));
   tree arg = PHI_ARG_DEF_FROM_EDGE (phi, e_in);
   // Avoid using the cache for ARGs defined in this block, as
   // that could create an ordering problem.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.