aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2015-01-09 11:14:55 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2015-01-09 11:14:55 +0000
commit2f2782497acb6efa025c1f832a37a0afeb3925f7 (patch)
tree03add0605b49b2b5c0f9393c96db9dfd878e15e2 /gcc/tree-ssa.c
parent520b30221300436cbc178a4110123c12ad3ee0ee (diff)
downloadgcc-2f2782497acb6efa025c1f832a37a0afeb3925f7.zip
gcc-2f2782497acb6efa025c1f832a37a0afeb3925f7.tar.gz
gcc-2f2782497acb6efa025c1f832a37a0afeb3925f7.tar.bz2
re PR tree-optimization/64410 (gcc 25% slower than clang 3.5 for adding complex numbers)
2015-01-09 Richard Biener <rguenther@suse.de> PR tree-optimization/64410 * tree-ssa.c (non_rewritable_lvalue_p): Allow REALPART/IMAGPART_EXPR on the LHS. (execute_update_addresses_taken): Deal with that. * tree-ssa-forwprop.c (pass_forwprop::execute): Use component-wise loads/stores for complex variables. * g++.dg/vect/pr64410.cc: New testcase. From-SVN: r219380
Diffstat (limited to 'gcc/tree-ssa.c')
-rw-r--r--gcc/tree-ssa.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index f48fc1d..ba6d5dd 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1330,6 +1330,13 @@ non_rewritable_lvalue_p (tree lhs)
if (DECL_P (lhs))
return false;
+ /* We can re-write REALPART_EXPR and IMAGPART_EXPR sets in
+ a reasonably efficient manner... */
+ if ((TREE_CODE (lhs) == REALPART_EXPR
+ || TREE_CODE (lhs) == IMAGPART_EXPR)
+ && DECL_P (TREE_OPERAND (lhs, 0)))
+ return false;
+
/* A decl that is wrapped inside a MEM-REF that covers
it full is also rewritable.
??? The following could be relaxed allowing component
@@ -1534,6 +1541,35 @@ execute_update_addresses_taken (void)
tree rhs, *rhsp = gimple_assign_rhs1_ptr (stmt);
tree sym;
+ /* Rewrite LHS IMAG/REALPART_EXPR similar to
+ gimplify_modify_expr_complex_part. */
+ if ((TREE_CODE (lhs) == IMAGPART_EXPR
+ || TREE_CODE (lhs) == REALPART_EXPR)
+ && DECL_P (TREE_OPERAND (lhs, 0))
+ && bitmap_bit_p (suitable_for_renaming,
+ DECL_UID (TREE_OPERAND (lhs, 0))))
+ {
+ tree other = make_ssa_name (TREE_TYPE (lhs));
+ tree lrhs = build1 (TREE_CODE (lhs) == IMAGPART_EXPR
+ ? REALPART_EXPR : IMAGPART_EXPR,
+ TREE_TYPE (other),
+ TREE_OPERAND (lhs, 0));
+ gimple load = gimple_build_assign (other, lrhs);
+ gimple_set_vuse (load, gimple_vuse (stmt));
+ gsi_insert_before (&gsi, load, GSI_SAME_STMT);
+ gimple_assign_set_lhs (stmt, TREE_OPERAND (lhs, 0));
+ gimple_assign_set_rhs_with_ops
+ (&gsi, COMPLEX_EXPR,
+ TREE_CODE (lhs) == IMAGPART_EXPR
+ ? other : gimple_assign_rhs1 (stmt),
+ TREE_CODE (lhs) == IMAGPART_EXPR
+ ? gimple_assign_rhs1 (stmt) : other, NULL_TREE);
+ stmt = gsi_stmt (gsi);
+ unlink_stmt_vdef (stmt);
+ update_stmt (stmt);
+ continue;
+ }
+
/* We shouldn't have any fancy wrapping of
component-refs on the LHS, but look through
VIEW_CONVERT_EXPRs as that is easy. */