aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Pinski <andrew_pinski@playstation.sony.com>2008-09-19 22:24:06 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2008-09-19 15:24:06 -0700
commitf22b7039d8ad71c2ceaf754087e4e52b18801201 (patch)
tree4ae3c868bf7b49aa4ef959bdc53b6374f3a03800 /gcc
parent8c3b36006dbd2f067b1ee1e465eb8f6056213836 (diff)
downloadgcc-f22b7039d8ad71c2ceaf754087e4e52b18801201.zip
gcc-f22b7039d8ad71c2ceaf754087e4e52b18801201.tar.gz
gcc-f22b7039d8ad71c2ceaf754087e4e52b18801201.tar.bz2
re PR tree-optimization/30930 (vector can cause to create an extra variable, DECL_GIMPLE_REG_P not recomputed)
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vector-2.c22
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/vector-3.c20
-rw-r--r--gcc/tree-ssa.c78
5 files changed, 113 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3d86e5b..efb7428 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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>
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 247d214..1e5d4d4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..2ce4388
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vector-2.c
@@ -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
index 0000000..332e127
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vector-3.c
@@ -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" } } */
+
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 6a1f6f3..073e129 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -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;