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]

Fix alpha bootstraps


This should fix the alpha bootstrap failure that rth was having.
It also includes a fixlet for tree-ssa-dom.c.  We were allocating
an array of basic blocks using n_basic_blocks and then indexing
the array with bb->index.

I don't have an alpha handy, so I don't really know if there are
any others like this one lurking around.  But I'm sure rth will
let me know in no uncertain terms.

Bootstrapped and tested ia64, x86-64, x86 and ppc64.


Diego.


	* tree-ssa-dom.c (record_edge_info): Use last_basic_block to
	allocate info array.
	* tree-vrp.c (extract_range_from_unary_expr): Set resulting
	range to varying in cast expressions that change
	TYPE_PRECISION.

testsuite/ChangeLog

	* gcc.dg/tree-ssa/vrp14.c: New test.

Index: tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.117
diff -d -u -p -r2.117 tree-ssa-dom.c
--- tree-ssa-dom.c	1 Jun 2005 02:51:01 -0000	2.117
+++ tree-ssa-dom.c	3 Jun 2005 21:01:59 -0000
@@ -2422,7 +2422,7 @@ record_edge_info (basic_block bb)
 	    {
 	      tree labels = SWITCH_LABELS (stmt);
 	      int i, n_labels = TREE_VEC_LENGTH (labels);
-	      tree *info = xcalloc (n_basic_blocks, sizeof (tree));
+	      tree *info = xcalloc (last_basic_block, sizeof (tree));
 	      edge e;
 	      edge_iterator ei;
 
Index: tree-vrp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vrp.c,v
retrieving revision 2.22
diff -d -u -p -r2.22 tree-vrp.c
--- tree-vrp.c	2 Jun 2005 21:54:39 -0000	2.22
+++ tree-vrp.c	3 Jun 2005 21:02:00 -0000
@@ -1295,17 +1295,23 @@ extract_range_from_unary_expr (value_ran
     }
 
   /* Handle unary expressions on integer ranges.  */
-  if ((code == NOP_EXPR || code == CONVERT_EXPR)
-      && (TYPE_SIZE (TREE_TYPE (vr0.min)) != TYPE_SIZE (TREE_TYPE (expr))))
+  if (code == NOP_EXPR || code == CONVERT_EXPR)
     {
+      tree inner_type = TREE_TYPE (op0);
+      tree outer_type = TREE_TYPE (expr);
+
       /* When converting types of different sizes, set the result to
 	 VARYING.  Things like sign extensions and precision loss may
 	 change the range.  For instance, if x_3 is of type 'long long
 	 int' and 'y_5 = (unsigned short) x_3', if x_3 is ~[0, 0], it
 	 is impossible to know at compile time whether y_5 will be
 	 ~[0, 0].  */
-      set_value_range_to_varying (vr);
-      return;
+      if (TYPE_SIZE (inner_type) != TYPE_SIZE (outer_type)
+	  || TYPE_PRECISION (inner_type) != TYPE_PRECISION (outer_type))
+	{
+	  set_value_range_to_varying (vr);
+	  return;
+	}
     }
 
   /* Apply the operation to each end of the range and see what we end
Index: testsuite/gcc.dg/tree-ssa/vrp14.c
===================================================================
RCS file: testsuite/gcc.dg/tree-ssa/vrp14.c
diff -N testsuite/gcc.dg/tree-ssa/vrp14.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/tree-ssa/vrp14.c	3 Jun 2005 21:02:01 -0000
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+struct tree_decl
+{
+  union tree_decl_u1 {
+    int f;
+    long i;
+    struct tree_decl_u1_a {
+      unsigned int align : 24;
+      unsigned int off_align : 8;
+    } a;
+  } u1;
+};
+
+extern void abort (void);
+
+unsigned int
+assemble_variable (struct tree_decl decl)
+{
+  unsigned int align;
+
+  align = decl.u1.a.align;
+
+  if (align > (1 << ((8 * 4) < 64 ? (8 * 4) - 2 : 62)))
+    align = (1 << ((8 * 4) < 64 ? (8 * 4) - 2 : 62));
+
+  /* VRP should not be propagating 0 to the RHS of this assignment.
+     But it was erroneously applying a cast operation between types of
+     different precision.  align is an unsigned int with range [0,
+     0x4000000] but the .align field holds only 24 bits.  So the cast
+     was returning a [0, 0] range.  */
+  decl.u1.a.align = align;
+
+  return decl.u1.a.align;
+}
+
+main ()
+{
+  struct tree_decl decl;
+  decl.u1.a.align = 13;
+  unsigned int x = assemble_variable (decl);
+  if (x == 0)
+    abort ();
+  return 0;
+}


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