public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR88777, Out-of-range offsets building glibc test-tgmath2.c
@ 2019-01-10  7:19 Alan Modra
  2019-01-11 18:42 ` Jeff Law
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2019-01-10  7:19 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Sandiford, Jeff Law

bb-reorder is quite seriously broken if get_attr_min_length should
return INT_MAX, which it does for hppa on branches with r267666.

I went the wrong way with my min_attr_value r267666 change.  It seems
that it isn't important that a "can't calculate" value is returned
from recursive calls, but rather that it returns the minimum among
those the function can calculate, ie. a conservative minimum length.
That's what this patch does, going back to the behaviour of
min_attr_value prior to r267666, with an added comment to stop foolish
patches in future.

Bootstrapped and regression tested powerpc64le-linux.  OK?

	PR 88777
	PR 88614
	* genattrtab.c (min_fn): Don't translate values.
	(min_attr_value): Return INT_MAX when the value can't be calculated.
	Return minimum among any values that can be calculated.
	(max_attr_value): Adjust.

diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c
index 1dd4f142672..78816ba3179 100644
--- a/gcc/genattrtab.c
+++ b/gcc/genattrtab.c
@@ -1556,10 +1556,7 @@ max_fn (rtx exp)
 static rtx
 min_fn (rtx exp)
 {
-  int val = min_attr_value (exp);
-  if (val < 0)
-    val = INT_MAX;
-  return make_numeric_value (val);
+  return make_numeric_value (min_attr_value (exp));
 }
 
 static void
@@ -3786,11 +3783,10 @@ max_attr_value (rtx exp)
       current_max = max_attr_value (XEXP (exp, 0));
       if (current_max != INT_MAX)
 	{
-	  n = min_attr_value (XEXP (exp, 1));
-	  if (n == INT_MIN)
-	    current_max = INT_MAX;
-	  else
-	    current_max -= n;
+	  n = current_max;
+	  current_max = min_attr_value (XEXP (exp, 1));
+	  if (current_max != INT_MAX)
+	    current_max = n - current_max;
 	}
       break;
 
@@ -3831,8 +3827,11 @@ max_attr_value (rtx exp)
 }
 
 /* Given an attribute value expression, return the minimum value that
-   might be evaluated.  Return INT_MIN if the value can't be
-   calculated by this function.  */
+   might be evaluated.  Return INT_MAX if the value can't be
+   calculated by this function.  Note that when this function can
+   calculate one value inside IF_THEN_ELSE or some but not all values
+   inside COND, then it returns the minimum among those values it can
+   calculate.  */
 
 static int
 min_attr_value (rtx exp)
@@ -3852,34 +3851,33 @@ min_attr_value (rtx exp)
 
     case PLUS:
       current_min = min_attr_value (XEXP (exp, 0));
-      if (current_min != INT_MIN)
+      if (current_min != INT_MAX)
 	{
 	  n = current_min;
 	  current_min = min_attr_value (XEXP (exp, 1));
-	  if (current_min != INT_MIN)
+	  if (current_min != INT_MAX)
 	    current_min += n;
 	}
       break;
 
     case MINUS:
       current_min = min_attr_value (XEXP (exp, 0));
-      if (current_min != INT_MIN)
+      if (current_min != INT_MAX)
 	{
-	  n = max_attr_value (XEXP (exp, 1));
-	  if (n == INT_MAX)
-	    current_min = INT_MIN;
-	  else
-	    current_min -= n;
+	  n = current_min;
+	  current_min = max_attr_value (XEXP (exp, 1));
+	  if (current_min != INT_MAX)
+	    current_min = n - current_min;
 	}
       break;
 
     case MULT:
       current_min = min_attr_value (XEXP (exp, 0));
-      if (current_min != INT_MIN)
+      if (current_min != INT_MAX)
 	{
 	  n = current_min;
 	  current_min = min_attr_value (XEXP (exp, 1));
-	  if (current_min != INT_MIN)
+	  if (current_min != INT_MAX)
 	    current_min *= n;
 	}
       break;
@@ -3902,7 +3900,7 @@ min_attr_value (rtx exp)
       break;
 
     default:
-      current_min = INT_MIN;
+      current_min = INT_MAX;
       break;
     }
 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-03 17:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-10  7:19 [PATCH] PR88777, Out-of-range offsets building glibc test-tgmath2.c Alan Modra
2019-01-11 18:42 ` Jeff Law
2019-01-11 19:50   ` Richard Sandiford
2019-01-12  2:40     ` Alan Modra
2019-01-11 23:45   ` Alan Modra
2019-06-03 17:35     ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).