This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] [3.2 branch] Fix optimization/9768


Hi,

This is a regression from gcc 3.0.x on PA-RISC. Compiled on 
i586-redhat-linux-gnu for native and hppa-linux-gnu.

-- 
Eric Botcazou


2003-02-20  Randolph Chung  <tausq at debian dot org>
                   Eric Botcazou  <ebotcazou at libertysurf dot fr>

	PR optimization/9768
	Backport patch from mainline:

	2002-03-21  DJ Delorie  <dj at redhat dot com>

	* bb-reorder.c (make_reorder_chain_1): Protect against
	when redundant edges are omitted.
	* predict.c (dump_prediction): Likewise.


2003-02-20  Randolph Chung  <tausq at debian dot org>

	* gcc.c-torture/compile/20030220-1.c: New test.
Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.43.2.1
diff -u -p -r1.43.2.1 bb-reorder.c
--- bb-reorder.c	15 Jul 2002 16:19:38 -0000	1.43.2.1
+++ bb-reorder.c	20 Feb 2003 17:42:11 -0000
@@ -205,7 +205,7 @@ make_reorder_chain_1 (bb, prev)
 	    e_taken = e;
 	}
 
-      next = (taken ? e_taken : e_fall)->dest;
+      next = ((taken && e_taken) ? e_taken : e_fall)->dest;
     }
 
   /* In the absence of a prediction, disturb things as little as possible
Index: predict.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/predict.c,v
retrieving revision 1.55.2.1
diff -u -p -r1.55.2.1 predict.c
--- predict.c	4 Apr 2002 21:37:47 -0000	1.55.2.1
+++ predict.c	20 Feb 2003 17:42:28 -0000
@@ -194,7 +194,7 @@ dump_prediction (predictor, probability,
   if (!rtl_dump_file)
     return;
 
-  while (e->flags & EDGE_FALLTHRU)
+  while (e && (e->flags & EDGE_FALLTHRU))
     e = e->succ_next;
 
   fprintf (rtl_dump_file, "  %s heuristics%s: %.1f%%",
@@ -205,9 +205,12 @@ dump_prediction (predictor, probability,
     {
       fprintf (rtl_dump_file, "  exec ");
       fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC, bb->count);
-      fprintf (rtl_dump_file, " hit ");
-      fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC, e->count);
-      fprintf (rtl_dump_file, " (%.1f%%)", e->count * 100.0 / bb->count);
+      if (e)
+	{
+	  fprintf (rtl_dump_file, " hit ");
+	  fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC, e->count);
+	  fprintf (rtl_dump_file, " (%.1f%%)", e->count * 100.0 / bb->count);
+	}
     }
 
   fprintf (rtl_dump_file, "\n");
/* PR optimization/9768 */
/* Originator: Randolph Chung <tausq at debian dot org> */

inline int fixfloor (long x)
{
  if (x >= 0)
    return (x >> 16);
  else
    return ~((~x) >> 16);
}

inline int fixtoi (long x)
{
  return fixfloor(x) + ((x & 0x8000) >> 15);
}

int foo(long x, long y)
{
  return fixtoi(x*y);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]