OSDN Git Service

2009-03-02 Sebastian Pop <sebastian.pop@amd.com>
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Mar 2009 03:47:22 +0000 (03:47 +0000)
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Mar 2009 03:47:22 +0000 (03:47 +0000)
PR middle-end/39335
* tree-parloops.c (canonicalize_loop_ivs): Call fold_convert
when the type precision of the induction variable should be
larger than the type precision of nit.
(gen_parallel_loop): Update use of canonicalize_loop_ivs.
* graphite.c (graphite_loop_normal_form): Same.
* tree-flow.h (canonicalize_loop_ivs): Update declaration.

* testsuite/gcc.dg/graphite/pr39335_1.c: New.
* testsuite/gcc.dg/graphite/pr39335.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144564 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/graphite.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/graphite/pr39335.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/graphite/pr39335_1.c [new file with mode: 0644]
gcc/tree-flow.h
gcc/tree-parloops.c

index 7a2df23..998ef44 100644 (file)
@@ -1,3 +1,13 @@
+2009-03-02  Sebastian Pop  <sebastian.pop@amd.com>
+
+       PR middle-end/39335
+       * tree-parloops.c (canonicalize_loop_ivs): Call fold_convert
+       when the type precision of the induction variable should be
+       larger than the type precision of nit.
+       (gen_parallel_loop): Update use of canonicalize_loop_ivs.
+       * graphite.c (graphite_loop_normal_form): Same.
+       * tree-flow.h (canonicalize_loop_ivs): Update declaration.
+
 2009-03-02  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.md (ST?_REG, MM?_REG): New constants.
 2009-03-02  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.md (ST?_REG, MM?_REG): New constants.
index 69a72fc..9b36284 100644 (file)
@@ -2395,7 +2395,7 @@ graphite_loop_normal_form (loop_p loop)
   if (nb_reductions_in_loop (loop) > 0)
     return NULL_TREE;
 
   if (nb_reductions_in_loop (loop) > 0)
     return NULL_TREE;
 
-  return canonicalize_loop_ivs (loop, NULL, nit);
+  return canonicalize_loop_ivs (loop, NULL, &nit);
 }
 
 /* Record LOOP as occuring in SCOP.  Returns true when the operation
 }
 
 /* Record LOOP as occuring in SCOP.  Returns true when the operation
index 4031eee..983fe83 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-02  Sebastian Pop  <sebastian.pop@amd.com>
+
+       PR middle-end/39335
+       * testsuite/gcc.dg/graphite/pr39335_1.c: New.
+       * testsuite/gcc.dg/graphite/pr39335.c: New.
+
 2009-03-02  H.J. Lu  <hongjiu.lu@intel.com>
 
        * gcc.target/i386/stackalign/return-4.c: Scan andl/andq instead
 2009-03-02  H.J. Lu  <hongjiu.lu@intel.com>
 
        * gcc.target/i386/stackalign/return-4.c: Scan andl/andq instead
diff --git a/gcc/testsuite/gcc.dg/graphite/pr39335.c b/gcc/testsuite/gcc.dg/graphite/pr39335.c
new file mode 100644 (file)
index 0000000..c86e03a
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-options "-O2 -floop-interchange" } */
+
+typedef unsigned char byte;
+typedef struct gx_device_s gx_device;
+typedef struct gs_devn_params_s gs_devn_params;
+typedef struct gs_devn_params_s {
+   struct compressed_color_list_s * compressed_color_list;
+} gs_devn_params_t;
+int devn_unpack_row(gx_device * dev, int num_comp,
+                   gs_devn_params * pdevn_params, int width, byte * in,
+                   byte * out)
+{
+ int i, comp_num, pixel_num;
+ if (pdevn_params->compressed_color_list == ((void *)0))
+   {
+     for (pixel_num = 0; pixel_num < width; pixel_num++)
+       for (i = 0; i < num_comp; i++)
+         *out++ = *in++;
+   }
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/pr39335_1.c b/gcc/testsuite/gcc.dg/graphite/pr39335_1.c
new file mode 100644 (file)
index 0000000..257c2c9
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-options "-O2 -floop-interchange" } */
+
+void crash_me(int num1, int num2, char * in, char * out)
+{
+ int i, j;
+ for (j = 0; j < num1; j++)
+   for (i = 0; i < num2; i++)
+     *out++ = *in++;
+}
index 3bedd35..01953b5 100644 (file)
@@ -991,7 +991,7 @@ unsigned int tree_ssa_prefetch_arrays (void);
 unsigned int remove_empty_loops (void);
 void tree_ssa_iv_optimize (void);
 unsigned tree_predictive_commoning (void);
 unsigned int remove_empty_loops (void);
 void tree_ssa_iv_optimize (void);
 unsigned tree_predictive_commoning (void);
-tree canonicalize_loop_ivs (struct loop *, htab_t, tree);
+tree canonicalize_loop_ivs (struct loop *, htab_t, tree *);
 bool parallelize_loops (void);
 
 bool loop_only_exit_p (const struct loop *, const_edge);
 bool parallelize_loops (void);
 
 bool loop_only_exit_p (const struct loop *, const_edge);
index f1d7227..f2d0ff6 100644 (file)
@@ -1321,16 +1321,20 @@ create_loop_fn (void)
   return decl;
 }
 
   return decl;
 }
 
-/* Bases all the induction variables in LOOP on a single induction variable
-   (unsigned with base 0 and step 1), whose final value is compared with
-   NIT.  The induction variable is incremented in the loop latch.  
-   REDUCTION_LIST describes the reductions in LOOP.  Return the induction 
-   variable that was created.  */
+/* Bases all the induction variables in LOOP on a single induction
+   variable (unsigned with base 0 and step 1), whose final value is
+   compared with *NIT.  When the IV type precision has to be larger
+   than *NIT type precision, *NIT is converted to the larger type, the
+   conversion code is inserted before the loop, and *NIT is updated to
+   the new definition.  The induction variable is incremented in the
+   loop latch.  REDUCTION_LIST describes the reductions in LOOP.
+   Return the induction variable that was created.  */
 
 tree
 
 tree
-canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
+canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree *nit)
 {
 {
-  unsigned precision = TYPE_PRECISION (TREE_TYPE (nit));
+  unsigned precision = TYPE_PRECISION (TREE_TYPE (*nit));
+  unsigned original_precision = precision;
   tree res, type, var_before, val, atype, mtype;
   gimple_stmt_iterator gsi, psi;
   gimple phi, stmt;
   tree res, type, var_before, val, atype, mtype;
   gimple_stmt_iterator gsi, psi;
   gimple phi, stmt;
@@ -1338,6 +1342,7 @@ canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
   affine_iv iv;
   edge exit = single_dom_exit (loop);
   struct reduction_info *red;
   affine_iv iv;
   edge exit = single_dom_exit (loop);
   struct reduction_info *red;
+  gimple_seq stmts;
 
   for (psi = gsi_start_phis (loop->header);
        !gsi_end_p (psi); gsi_next (&psi))
 
   for (psi = gsi_start_phis (loop->header);
        !gsi_end_p (psi); gsi_next (&psi))
@@ -1351,6 +1356,14 @@ canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
 
   type = lang_hooks.types.type_for_size (precision, 1);
 
 
   type = lang_hooks.types.type_for_size (precision, 1);
 
+  if (original_precision != precision)
+    {
+      *nit = fold_convert (type, *nit);
+      *nit = force_gimple_operand (*nit, &stmts, true, NULL_TREE);
+      if (stmts)
+       gsi_insert_seq_on_edge_immediate (loop_preheader_edge (loop), stmts);
+    }
+
   gsi = gsi_last_bb (loop->latch);
   create_iv (build_int_cst_type (type, 0), build_int_cst (type, 1), NULL_TREE,
             loop, &gsi, true, &var_before, NULL);
   gsi = gsi_last_bb (loop->latch);
   create_iv (build_int_cst_type (type, 0), build_int_cst (type, 1), NULL_TREE,
             loop, &gsi, true, &var_before, NULL);
@@ -1410,7 +1423,7 @@ canonicalize_loop_ivs (struct loop *loop, htab_t reduction_list, tree nit)
     }
   gimple_cond_set_code (stmt, LT_EXPR);
   gimple_cond_set_lhs (stmt, var_before);
     }
   gimple_cond_set_code (stmt, LT_EXPR);
   gimple_cond_set_lhs (stmt, var_before);
-  gimple_cond_set_rhs (stmt, nit);
+  gimple_cond_set_rhs (stmt, *nit);
   update_stmt (stmt);
 
   return var_before;
   update_stmt (stmt);
 
   return var_before;
@@ -1760,7 +1773,7 @@ gen_parallel_loop (struct loop *loop, htab_t reduction_list,
   free_original_copy_tables ();
 
   /* Base all the induction variables in LOOP on a single control one.  */
   free_original_copy_tables ();
 
   /* Base all the induction variables in LOOP on a single control one.  */
-  canonicalize_loop_ivs (loop, reduction_list, nit);
+  canonicalize_loop_ivs (loop, reduction_list, &nit);
 
   /* Ensure that the exit condition is the first statement in the loop.  */
   transform_to_exit_first_loop (loop, reduction_list, nit);
 
   /* Ensure that the exit condition is the first statement in the loop.  */
   transform_to_exit_first_loop (loop, reduction_list, nit);