https://gcc.gnu.org/g:e5e341243bf4a8a93fc9b5776124c64015326356

commit r15-1347-ge5e341243bf4a8a93fc9b5776124c64015326356
Author: Andrew MacLeod <amacl...@redhat.com>
Date:   Fri Jun 14 11:01:08 2024 -0400

    Dont add varying values to gori_on_edge mass calculations.
    
    gori_on_edge will return an ssa_lazy_cache with all contextual ranges
    that can be generated by an edge.   This patch adjusts it so that
    a VARYING range is never added.
    
            * gimple-range-gori.cc (gori_calc_operands): Do not continue nor
            add the range when VARYING is produced for an operand.

Diff:
---
 gcc/gimple-range-gori.cc | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index d489aef312ce..4f6073c715af 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -1605,11 +1605,14 @@ gori_calc_operands (vrange &lhs, gimple *stmt, 
ssa_cache &r, range_query *q)
       tmp.set_type (TREE_TYPE (si.ssa1));
       if (si.calc_op1 (tmp, lhs, si.op2_range))
        si.op1_range.intersect (tmp);
-      r.set_range (si.ssa1, si.op1_range);
-      gimple *src = SSA_NAME_DEF_STMT (si.ssa1);
-      // If defintion is in the same basic lock, evaluate it.
-      if (src && gimple_bb (src) == gimple_bb (stmt))
-       gori_calc_operands (si.op1_range, src, r, q);
+      if (!si.op1_range.varying_p ())
+       {
+         r.set_range (si.ssa1, si.op1_range);
+         gimple *src = SSA_NAME_DEF_STMT (si.ssa1);
+         // If defintion is in the same basic lock, evaluate it.
+         if (src && gimple_bb (src) == gimple_bb (stmt))
+           gori_calc_operands (si.op1_range, src, r, q);
+       }
     }
 
   if (si.ssa2 && !r.has_range (si.ssa2))
@@ -1617,10 +1620,13 @@ gori_calc_operands (vrange &lhs, gimple *stmt, 
ssa_cache &r, range_query *q)
       tmp.set_type (TREE_TYPE (si.ssa2));
       if (si.calc_op2 (tmp, lhs, si.op1_range))
        si.op2_range.intersect (tmp);
-      r.set_range (si.ssa2, si.op2_range);
-      gimple *src = SSA_NAME_DEF_STMT (si.ssa2);
-      if (src && gimple_bb (src) == gimple_bb (stmt))
-       gori_calc_operands (si.op2_range, src, r, q);
+      if (!si.op2_range.varying_p ())
+       {
+         r.set_range (si.ssa2, si.op2_range);
+         gimple *src = SSA_NAME_DEF_STMT (si.ssa2);
+         if (src && gimple_bb (src) == gimple_bb (stmt))
+           gori_calc_operands (si.op2_range, src, r, q);
+       }
     }
 }

Reply via email to