]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/30930 (vector can cause to create an extra variable, DECL_GIM...
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Fri, 19 Sep 2008 22:24:06 +0000 (22:24 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Fri, 19 Sep 2008 22:24:06 +0000 (15:24 -0700)
2008-09-19  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/30930
        * tree-ssa.c (execute_update_addresses_taken): Also update
        DECL_GIMPLE_REG_P for vector and complex types.

2008-09-19  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR tree-opt/30930
        * gcc.dg/tree-ssa/vector-2.c: New test.
        * gcc.dg/tree-ssa/vector-3.c: New test.

From-SVN: r140501

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/vector-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/vector-3.c [new file with mode: 0644]
gcc/tree-ssa.c

index 3d86e5bf5d918f4be5eacf06c12fef7ca4ab28d8..efb74280321bfe6f963716fc0519591a9386849f 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-19  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR tree-opt/30930
+       * tree-ssa.c (execute_update_addresses_taken): Also update
+       DECL_GIMPLE_REG_P for vector and complex types.
+
 2008-09-19  Andrew MacLeod  <amacleod@redhat.com>
            Jan Hubicka  <jh@suse.cz>
 
index 247d214cb4729458b887d1fd0a1b501cb21d895b..1e5d4d4e04a6d4bc48862353d770044150e0a7ac 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-19  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       PR tree-opt/30930
+       * gcc.dg/tree-ssa/vector-2.c: New test.
+       * gcc.dg/tree-ssa/vector-3.c: New test.
+
 2008-09-18  Bob Wilson  <bob.wilson@acm.org>
        
        * gcc.c-torture/compile/pr11832.c: xfail on xtensa*-*-*.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vector-2.c b/gcc/testsuite/gcc.dg/tree-ssa/vector-2.c
new file mode 100644 (file)
index 0000000..2ce4388
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-w -O1 -fdump-tree-final_cleanup" } */
+
+#define vector __attribute__(( vector_size(16) ))
+
+float f(vector float a, int b, vector float c)
+{
+  vector float dd = c*a;
+  a = (vector float){0,0,0,0};
+  c = (vector float){0,0,0,0};
+  {
+   float d = ((float*)&a)[0];
+   float d1 = ((float*)&c)[0];
+   return d*d1;
+  }
+}
+
+/* We should be able to optimize this to just "return 0.0;" */
+/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 0 "final_cleanup"} } */
+/* { dg-final { scan-tree-dump-times "0.0" 1 "final_cleanup"} } */
+
+/* { dg-final { cleanup-tree-dump "final_cleanup" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vector-3.c b/gcc/testsuite/gcc.dg/tree-ssa/vector-3.c
new file mode 100644 (file)
index 0000000..332e127
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-w -O1 -fdump-tree-final_cleanup" } */
+
+#define vector __attribute((vector_size(16) ))
+vector float a;
+
+float f(float b)
+{
+  vector float c = {0, 0, 0, 0};
+  vector float d = {0, 0, 0, 0};
+  d += c;
+  return ((float*)&c)[2];
+}
+
+/* We should be able to optimize this to just "return 0.0;" */
+/* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 0 "final_cleanup"} } */
+/* { dg-final { scan-tree-dump-times "0.0" 1 "final_cleanup"} } */
+
+/* { dg-final { cleanup-tree-dump "final_cleanup" } } */
+
index 6a1f6f353c8e7735992760d8f90fb4d7d1d889dd..073e1290b3cb475c58ee0bc7e5963bd5a739fb6d 100644 (file)
@@ -1653,7 +1653,7 @@ struct gimple_opt_pass pass_late_warn_uninitialized =
  }
 };
 
-/* Compute TREE_ADDRESSABLE for local variables.  */
+/* Compute TREE_ADDRESSABLE and DECL_GIMPLE_REG_P for local variables.  */
 
 static unsigned int
 execute_update_addresses_taken (void)
@@ -1663,6 +1663,7 @@ execute_update_addresses_taken (void)
   gimple_stmt_iterator gsi;
   basic_block bb;
   bitmap addresses_taken = BITMAP_ALLOC (NULL);
+  bitmap not_reg_needs = BITMAP_ALLOC (NULL);
   bitmap vars_updated = BITMAP_ALLOC (NULL);
   bool update_vops = false;
 
@@ -1672,9 +1673,26 @@ execute_update_addresses_taken (void)
     {
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
        {
-         bitmap taken = gimple_addresses_taken (gsi_stmt (gsi));
+         const_gimple stmt = gsi_stmt (gsi);
+         enum gimple_code code = gimple_code (stmt);
+         bitmap taken = gimple_addresses_taken (stmt);
+         
          if (taken)
            bitmap_ior_into (addresses_taken, taken);
+         
+         /* If we have a call or an assignment, see if the lhs contains
+            a local decl that requires not to be a gimple register.  */
+         if (code == GIMPLE_ASSIGN || code == GIMPLE_CALL)
+           {
+             tree lhs = gimple_get_lhs (stmt);
+             /* A plain decl does not need it set.  */
+             if (lhs && handled_component_p (lhs))
+               {
+                 var = get_base_address (lhs);
+                 if (DECL_P (var))
+                   bitmap_set_bit (not_reg_needs, DECL_UID (var));
+               }
+           }
        }
 
       for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
@@ -1693,25 +1711,46 @@ execute_update_addresses_taken (void)
        }
     }
 
-  /* When possible, clear ADDRESSABLE bit and mark variable for conversion into
-     SSA.  */
+  /* When possible, clear ADDRESSABLE bit or set the REGISTER bit
+     and mark variable for conversion into SSA.  */
   FOR_EACH_REFERENCED_VAR (var, rvi)
-    if (!is_global_var (var)
-       && TREE_CODE (var) != RESULT_DECL
-       && TREE_ADDRESSABLE (var)
-       && !bitmap_bit_p (addresses_taken, DECL_UID (var)))
-      {
-        TREE_ADDRESSABLE (var) = 0;
-       if (is_gimple_reg (var))
+    {
+      /* Global Variables, result decls cannot be changed.  */
+      if (is_global_var (var)
+          || TREE_CODE (var) == RESULT_DECL
+         || bitmap_bit_p (addresses_taken, DECL_UID (var)))
+       continue;
+       
+      if (TREE_ADDRESSABLE (var))
+       {
+         TREE_ADDRESSABLE (var) = 0;
+         if (is_gimple_reg (var))
+           mark_sym_for_renaming (var);
+         update_vops = true;
+         bitmap_set_bit (vars_updated, DECL_UID (var));
+         if (dump_file)
+           {
+             fprintf (dump_file, "No longer having address taken ");
+             print_generic_expr (dump_file, var, 0);
+             fprintf (dump_file, "\n");
+           }
+       }
+      if (!DECL_GIMPLE_REG_P (var)
+         && !bitmap_bit_p (not_reg_needs, DECL_UID (var))
+         && (TREE_CODE (TREE_TYPE (var)) == COMPLEX_TYPE
+             || TREE_CODE (TREE_TYPE (var)) == VECTOR_TYPE))
+       {
+         DECL_GIMPLE_REG_P (var) = 1;
          mark_sym_for_renaming (var);
-       update_vops = true;
-       bitmap_set_bit (vars_updated, DECL_UID (var));
-       if (dump_file)
-         {
-           fprintf (dump_file, "No longer having address taken ");
-           print_generic_expr (dump_file, var, 0);
-           fprintf (dump_file, "\n");
-         }
+         update_vops = true;
+         bitmap_set_bit (vars_updated, DECL_UID (var));
+         if (dump_file)
+           {
+             fprintf (dump_file, "Decl is now a gimple register ");
+             print_generic_expr (dump_file, var, 0);
+             fprintf (dump_file, "\n");
+           }
+       }
       }
 
   /* Operand caches needs to be recomputed for operands referencing the updated
@@ -1728,6 +1767,7 @@ execute_update_addresses_taken (void)
                  && bitmap_intersect_p (gimple_stored_syms (stmt), vars_updated)))
            update_stmt (stmt);
        }
+  BITMAP_FREE (not_reg_needs);
   BITMAP_FREE (addresses_taken);
   BITMAP_FREE (vars_updated);
   return 0;