OSDN Git Service

2009-10-14 Sebastian Pop <sebastian.pop@amd.com>
[pf3gnuchains/gcc-fork.git] / gcc / matrix-reorg.c
index 846a813..d2687b8 100644 (file)
@@ -1,5 +1,5 @@
 /* Matrix layout transformations.
-   Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
    Contributed by Razya Ladelsky <razya@il.ibm.com>
    Originally written by Revital Eres and Mustafa Hagog.
    
@@ -115,7 +115,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tm.h"
 #include "tree.h"
 #include "rtl.h"
-#include "c-tree.h"
 #include "tree-inline.h"
 #include "tree-flow.h"
 #include "tree-flow-inline.h"
@@ -131,7 +130,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "timevar.h"
 #include "params.h"
 #include "fibheap.h"
-#include "c-common.h"
 #include "intl.h"
 #include "function.h"
 #include "basic-block.h"
@@ -142,6 +140,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-data-ref.h"
 #include "tree-chrec.h"
 #include "tree-scalar-evolution.h"
+#include "tree-ssa-sccvn.h"
 
 /* We need to collect a lot of data from the original malloc,
    particularly as the gimplifier has converted:
@@ -245,6 +244,14 @@ typedef struct access_site_info *access_site_info_p;
 DEF_VEC_P (access_site_info_p);
 DEF_VEC_ALLOC_P (access_site_info_p, heap);
 
+/* Calls to free when flattening a matrix.  */
+
+struct free_info
+{
+  gimple stmt;
+  tree func;
+};
+
 /* Information about matrix to flatten.  */
 struct matrix_info
 {
@@ -261,9 +268,6 @@ struct matrix_info
 
   gimple min_indirect_level_escape_stmt;
 
-  /* Is the matrix transposed.  */
-  bool is_transposed_p;
-
   /* Hold the allocation site for each level (dimension).
      We can use NUM_DIMS as the upper bound and allocate the array
      once with this number of elements and no need to use realloc and
@@ -272,16 +276,15 @@ struct matrix_info
 
   int max_malloced_level;
 
+  /* Is the matrix transposed.  */
+  bool is_transposed_p;
+
   /* The location of the allocation sites (they must be in one
      function).  */
   tree allocation_function_decl;
 
   /* The calls to free for each level of indirection.  */
-  struct free_info
-  {
-    gimple stmt;
-    tree func;
-  } *free_stmts;
+  struct free_info *free_stmts;
 
   /* An array which holds for each dimension its size. where
      dimension 0 is the outer most (one that contains all the others).
@@ -303,7 +306,7 @@ struct matrix_info
 
   /* An array of the accesses to be flattened.
      elements are of type "struct access_site_info *".  */
-    VEC (access_site_info_p, heap) * access_l;
+  VEC (access_site_info_p, heap) * access_l;
 
   /* A map of how the dimensions will be organized at the end of 
      the analyses.  */
@@ -658,8 +661,7 @@ ssa_accessed_in_assign_rhs (gimple stmt, struct ssa_acc_in_tree *a)
 
     case SSA_NAME:
     case INDIRECT_REF:
-    case CONVERT_EXPR:
-    case NOP_EXPR:
+    CASE_CONVERT:
     case VIEW_CONVERT_EXPR:
       ssa_accessed_in_tree (gimple_assign_rhs1 (stmt), a);
       break;
@@ -931,7 +933,7 @@ analyze_transpose (void **slot, void *data ATTRIBUTE_UNUSED)
              free (acc_info);
              continue;
            }
-         if (simple_iv (loop, acc_info->stmt, acc_info->offset, &iv, true))
+         if (simple_iv (loop, loop, acc_info->offset, &iv, true))
            {
              if (iv.step != NULL)
                {
@@ -1602,7 +1604,7 @@ check_allocation_function (void **slot, void *data ATTRIBUTE_UNUSED)
     {
       gimple call_stmt;
       tree size;
-      struct malloc_call_data mcd;
+      struct malloc_call_data mcd = {NULL, NULL_TREE, NULL_TREE};
 
       call_stmt = mi->malloc_for_level[level];
 
@@ -1755,16 +1757,20 @@ record_all_accesses_in_func (void)
   sbitmap_free (visited_stmts_1);
 }
 
-/* Used when we want to convert the expression: RESULT =  something * ORIG to RESULT = something * NEW. If ORIG and NEW are power of 2, shift operations can be done, else division and multiplication.  */
+/* Used when we want to convert the expression: RESULT = something *
+   ORIG to RESULT = something * NEW_VAL. If ORIG and NEW_VAL are power
+   of 2, shift operations can be done, else division and
+   multiplication.  */
+
 static tree
-compute_offset (HOST_WIDE_INT orig, HOST_WIDE_INT new, tree result)
+compute_offset (HOST_WIDE_INT orig, HOST_WIDE_INT new_val, tree result)
 {
 
   int x, y;
   tree result1, ratio, log, orig_tree, new_tree;
 
   x = exact_log2 (orig);
-  y = exact_log2 (new);
+  y = exact_log2 (new_val);
 
   if (x != -1 && y != -1)
     {
@@ -1783,7 +1789,7 @@ compute_offset (HOST_WIDE_INT orig, HOST_WIDE_INT new, tree result)
       return result1;
     }
   orig_tree = build_int_cst (TREE_TYPE (result), orig);
-  new_tree = build_int_cst (TREE_TYPE (result), new);
+  new_tree = build_int_cst (TREE_TYPE (result), new_val);
   ratio = fold_build2 (TRUNC_DIV_EXPR, TREE_TYPE (result), result, orig_tree);
   result1 = fold_build2 (MULT_EXPR, TREE_TYPE (result), ratio, new_tree);
 
@@ -1862,8 +1868,9 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED)
                    tmp = create_tmp_var (TREE_TYPE (lhs), "new");
                    add_referenced_var (tmp);
                    rhs = gimple_assign_rhs1 (acc_info->stmt);
-                   new_stmt = gimple_build_assign (tmp,
-                                                   TREE_OPERAND (rhs, 0));
+                   rhs = fold_convert (TREE_TYPE (tmp),
+                                       TREE_OPERAND (rhs, 0));
+                   new_stmt = gimple_build_assign (tmp, rhs);
                    tmp = make_ssa_name (tmp, new_stmt);
                    gimple_assign_set_lhs (new_stmt, tmp);
                    gsi = gsi_for_stmt (acc_info->stmt);
@@ -1959,6 +1966,7 @@ transform_access_sites (void **slot, void *data ATTRIBUTE_UNUSED)
                {
                  gcc_assert (TREE_CODE (offset) == INTEGER_CST);
                  gimple_assign_set_rhs2 (acc_info->stmt, tmp1);
+                 update_stmt (acc_info->stmt);
                }
            }
        }
@@ -2022,7 +2030,7 @@ transform_allocation_sites (void **slot, void *data ATTRIBUTE_UNUSED)
   struct cgraph_node *c_node;
   struct cgraph_edge *e;
   gimple_stmt_iterator gsi;
-  struct malloc_call_data mcd;
+  struct malloc_call_data mcd = {NULL, NULL_TREE, NULL_TREE};
   HOST_WIDE_INT element_size;
 
   imm_use_iterator imm_iter;
@@ -2415,12 +2423,11 @@ struct simple_ipa_opt_pass pass_ipa_matrix_reorg =
   NULL,                                /* sub */
   NULL,                                /* next */
   0,                           /* static_pass_number */
-  0,                           /* tv_id */
+  TV_NONE,                     /* tv_id */
   0,                           /* properties_required */
-  PROP_trees,                  /* properties_provided */
+  0,                           /* properties_provided */
   0,                           /* properties_destroyed */
   0,                           /* todo_flags_start */
   TODO_dump_cgraph | TODO_dump_func    /* todo_flags_finish */
  }
 };
-