OSDN Git Service

2009-04-16 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 16 Apr 2009 14:53:32 +0000 (14:53 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 16 Apr 2009 14:53:32 +0000 (14:53 +0000)
* tree-cfg.c (verify_gimple_assign_binary):
Allow POINTER_PLUS_EXPR-like PLUS_EXPR for vectors.
* ipa-struct-reorg.c (gen_size): Fold the built expressions.
(create_general_new_stmt): Note that this function is broken.

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

gcc/ChangeLog
gcc/ipa-struct-reorg.c
gcc/tree-cfg.c

index 04eb70a..b442250 100644 (file)
@@ -1,3 +1,10 @@
+2009-04-16  Richard Guenther  <rguenther@suse.de>
+
+       * tree-cfg.c (verify_gimple_assign_binary):
+       Allow POINTER_PLUS_EXPR-like PLUS_EXPR for vectors.
+       * ipa-struct-reorg.c (gen_size): Fold the built expressions.
+       (create_general_new_stmt): Note that this function is broken.
+
 2009-04-16  Rafael Avila de Espindola  <espindola@google.com>
 
        * common.opt (fhelp): Add Var(help_flag).
index 9ca5364..8b5360d 100644 (file)
@@ -606,13 +606,17 @@ gen_size (tree num, tree type, tree *res)
   if (exact_log2 (struct_size_int) == -1)
     {
       tree size = build_int_cst (TREE_TYPE (num), struct_size_int);
-      new_stmt = gimple_build_assign_with_ops (MULT_EXPR, *res, num, size);
+      new_stmt = gimple_build_assign (*res, fold_build2 (MULT_EXPR,
+                                                        TREE_TYPE (num),
+                                                        num, size));
     }
   else
     {
       tree C = build_int_cst (TREE_TYPE (num), exact_log2 (struct_size_int));
  
-      new_stmt = gimple_build_assign_with_ops (LSHIFT_EXPR, *res, num, C);
+      new_stmt = gimple_build_assign (*res, fold_build2 (LSHIFT_EXPR,
+                                                        TREE_TYPE (num),
+                                                        num, C));
     }
 
   finalize_stmt (new_stmt);
@@ -1291,6 +1295,8 @@ create_general_new_stmt (struct access_site *acc, tree new_type)
            {
              pos = find_pos_in_stmt (new_stmt, var);
              gcc_assert (pos);
+             /* ???  This misses adjustments to the type of the
+                INDIRECT_REF we possibly replace the operand of.  */
              *pos = new_var;
            }      
        }
index 447e6cf..2eab9ad 100644 (file)
@@ -3568,8 +3568,52 @@ verify_gimple_assign_binary (gimple stmt)
        return false;
       }
 
+    case PLUS_EXPR:
+      {
+       /* We use regular PLUS_EXPR for vectors.
+          ???  This just makes the checker happy and may not be what is
+          intended.  */
+       if (TREE_CODE (lhs_type) == VECTOR_TYPE
+           && POINTER_TYPE_P (TREE_TYPE (lhs_type)))
+         {
+           if (TREE_CODE (rhs1_type) != VECTOR_TYPE
+               || TREE_CODE (rhs2_type) != VECTOR_TYPE)
+             {
+               error ("invalid non-vector operands to vector valued plus");
+               return true;
+             }
+           lhs_type = TREE_TYPE (lhs_type);
+           rhs1_type = TREE_TYPE (rhs1_type);
+           rhs2_type = TREE_TYPE (rhs2_type);
+           /* PLUS_EXPR is commutative, so we might end up canonicalizing
+              the pointer to 2nd place.  */
+           if (POINTER_TYPE_P (rhs2_type))
+             {
+               tree tem = rhs1_type;
+               rhs1_type = rhs2_type;
+               rhs2_type = tem;
+             }
+           goto do_pointer_plus_expr_check;
+         }
+      }
+    /* Fallthru.  */
+    case MINUS_EXPR:
+      {
+       if (POINTER_TYPE_P (lhs_type)
+           || POINTER_TYPE_P (rhs1_type)
+           || POINTER_TYPE_P (rhs2_type))
+         {
+           error ("invalid (pointer) operands to plus/minus");
+           return true;
+         }
+
+       /* Continue with generic binary expression handling.  */
+       break;
+      }
+
     case POINTER_PLUS_EXPR:
       {
+do_pointer_plus_expr_check:
        if (!POINTER_TYPE_P (rhs1_type)
            || !useless_type_conversion_p (lhs_type, rhs1_type)
            || !useless_type_conversion_p (sizetype, rhs2_type))
@@ -3625,21 +3669,6 @@ verify_gimple_assign_binary (gimple stmt)
         connected to the operand types.  */
       return verify_gimple_comparison (lhs_type, rhs1, rhs2);
 
-    case PLUS_EXPR:
-    case MINUS_EXPR:
-      {
-       if (POINTER_TYPE_P (lhs_type)
-           || POINTER_TYPE_P (rhs1_type)
-           || POINTER_TYPE_P (rhs2_type))
-         {
-           error ("invalid (pointer) operands to plus/minus");
-           return true;
-         }
-
-       /* Continue with generic binary expression handling.  */
-       break;
-      }
-
     case WIDEN_SUM_EXPR:
     case WIDEN_MULT_EXPR:
     case VEC_WIDEN_MULT_HI_EXPR: