diff mbox series

[COMMITTED] Dont add varying values to gori_on_edge mass, calculations.

Message ID 57f13fee-e47c-4fdd-a7ab-06148e286dee@redhat.com
State New
Headers show
Series [COMMITTED] Dont add varying values to gori_on_edge mass, calculations. | expand

Commit Message

Andrew MacLeod June 14, 2024, 7:20 p.m. UTC
The 'gori_on_edge' routine is an API which provides all contextual names 
that can be calculated on an outgoing edge at once.   It provides this 
via the ssa_lazy_cache object.

This patch recognizes that if the value produces VARYING, we should not 
put it in the list, nor continue processing the dependency chain.

Bootstraps on  x86_64-pc-linux-gnu with no regressions.   Pushed.

Andrew
diff mbox series

Patch

From 2f90cb8b36affbb28dba643dd38068fc88c76e12 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Fri, 14 Jun 2024 11:01:08 -0400
Subject: [PATCH 3/7] 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.
---
 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 d489aef312c..4f6073c715a 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);
+	}
     }
 }
 
-- 
2.45.0