Fix PR49471: canonicalize_loop_ivs should not generate unsigned types.
authorSebastian Pop <sebastian.pop@amd.com>
Wed, 27 Jul 2011 16:53:09 +0000 (16:53 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Wed, 27 Jul 2011 16:53:09 +0000 (16:53 +0000)
2011-07-27  Sebastian Pop  <sebastian.pop@amd.com>

PR tree-optimization/49471
* tree-ssa-loop-manip.c (canonicalize_loop_ivs): Build an unsigned
iv only when the largest type is unsigned.  Do not call
lang_hooks.types.type_for_size.

* testsuite/libgomp.graphite/force-parallel-1.c: Un-xfail.
* testsuite/libgomp.graphite/force-parallel-2.c: Adjust pattern.

From-SVN: r176838

gcc/ChangeLog
gcc/tree-ssa-loop-manip.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.graphite/force-parallel-1.c
libgomp/testsuite/libgomp.graphite/force-parallel-2.c

index 46e8c0e55e3de97d24d385ee5a25af2a3880b731..b07d494d6797160475502882ef35d34c98430ad5 100644 (file)
@@ -1,3 +1,10 @@
+2011-07-27  Sebastian Pop  <sebastian.pop@amd.com>
+
+       PR tree-optimization/49471
+       * tree-ssa-loop-manip.c (canonicalize_loop_ivs): Build an unsigned
+       iv only when the largest type is unsigned.  Do not call
+       lang_hooks.types.type_for_size.
+
 2011-07-27  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR middle-end/45450
index 8176ed8d04cab3bd8ebe21db79191e3e13390233..0cec7872b8118faac7f1f86c2a6b80260a99def5 100644 (file)
@@ -1200,18 +1200,36 @@ canonicalize_loop_ivs (struct loop *loop, tree *nit, bool bump_in_latch)
   gimple stmt;
   edge exit = single_dom_exit (loop);
   gimple_seq stmts;
+  enum machine_mode mode;
+  bool unsigned_p = false;
 
   for (psi = gsi_start_phis (loop->header);
        !gsi_end_p (psi); gsi_next (&psi))
     {
       gimple phi = gsi_stmt (psi);
       tree res = PHI_RESULT (phi);
+      bool uns;
 
-      if (is_gimple_reg (res) && TYPE_PRECISION (TREE_TYPE (res)) > precision)
-       precision = TYPE_PRECISION (TREE_TYPE (res));
+      type = TREE_TYPE (res);
+      if (!is_gimple_reg (res)
+         || (!INTEGRAL_TYPE_P (type)
+             && !POINTER_TYPE_P (type))
+         || TYPE_PRECISION (type) < precision)
+       continue;
+
+      uns = POINTER_TYPE_P (type) | TYPE_UNSIGNED (type);
+
+      if (TYPE_PRECISION (type) > precision)
+       unsigned_p = uns;
+      else
+       unsigned_p |= uns;
+
+      precision = TYPE_PRECISION (type);
     }
 
-  type = lang_hooks.types.type_for_size (precision, 1);
+  mode = smallest_mode_for_size (precision, MODE_INT);
+  precision = GET_MODE_PRECISION (mode);
+  type = build_nonstandard_integer_type (precision, unsigned_p);
 
   if (original_precision != precision)
     {
index c6d9ffd9c95d6d3853d03cf9dc90f789a53dd5bf..b9455b416384c7a5ead869f72553b8c6ec890772 100644 (file)
@@ -1,3 +1,8 @@
+2011-07-23  Sebastian Pop  <sebastian.pop@amd.com>
+
+       * testsuite/libgomp.graphite/force-parallel-1.c: Un-xfail.
+       * testsuite/libgomp.graphite/force-parallel-2.c: Adjust pattern.
+
 2011-07-25  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        PR libgomp/45351
index 71ed3324307f7b8d43beb819d8ae8223c392255b..7f043d83d8b11fce586eb6f65b2f6cda0438eceb 100644 (file)
@@ -23,7 +23,7 @@ int main(void)
 }
 
 /* Check that parallel code generation part make the right answer.  */
-/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 2 "graphite" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "1 loops carried no dependency" 2 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 /* { dg-final { scan-tree-dump-times "loopfn" 5 "optimized" } } */
 /* { dg-final { cleanup-tree-dump "parloops" } } */
index 1ce0feb250606a24c928cc0a66abbc6dc12786bc..03d823653a7475b59ef480a1e0789926b3855062 100644 (file)
@@ -23,7 +23,7 @@ int main(void)
 }
 
 /* Check that parallel code generation part make the right answer.  */
-/* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 1 "graphite" } } */
+/* { dg-final { scan-tree-dump-times "2 loops carried no dependency" 2 "graphite" } } */
 /* { dg-final { cleanup-tree-dump "graphite" } } */
 /* { dg-final { scan-tree-dump-times "loopfn" 5 "optimized" } } */
 /* { dg-final { cleanup-tree-dump "parloops" } } */