summaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authormatz <matz@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-15 14:46:36 +0000
committermatz <matz@138bc75d-0d04-0410-961f-82ee72b054a4>2012-06-15 14:46:36 +0000
commit930802aa5979d14a3e03f188998805d422643749 (patch)
tree52ddf82808940117f11925d8592a4fa676566921 /gcc/gimplify.c
parent8f1c7d1974f3a7f6551dcc5ce7821872f0f97d62 (diff)
downloadgcc-930802aa5979d14a3e03f188998805d422643749.tar.gz
* gimplify.c (gimplify_compound_literal_expr): Take gimple_test_f
argument, don't emit assign statement if value is directly usable. (gimplify_expr): Adjust. testsuite/ * gcc.dg/tree-ssa/vector-4.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@188665 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index c59e754bb6f..9bf4ead84ed 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -3796,15 +3796,29 @@ rhs_predicate_for (tree lhs)
static enum gimplify_status
gimplify_compound_literal_expr (tree *expr_p, gimple_seq *pre_p,
+ bool (*gimple_test_f) (tree),
fallback_t fallback)
{
tree decl_s = COMPOUND_LITERAL_EXPR_DECL_EXPR (*expr_p);
tree decl = DECL_EXPR_DECL (decl_s);
+ tree init = DECL_INITIAL (decl);
/* Mark the decl as addressable if the compound literal
expression is addressable now, otherwise it is marked too late
after we gimplify the initialization expression. */
if (TREE_ADDRESSABLE (*expr_p))
TREE_ADDRESSABLE (decl) = 1;
+ /* Otherwise, if we don't need an lvalue and have a literal directly
+ substitute it. Check if it matches the gimple predicate, as
+ otherwise we'd generate a new temporary, and we can as well just
+ use the decl we already have. */
+ else if (!TREE_ADDRESSABLE (decl)
+ && init
+ && (fallback & fb_lvalue) == 0
+ && gimple_test_f (init))
+ {
+ *expr_p = init;
+ return GS_OK;
+ }
/* Preliminarily mark non-addressed complex variables as eligible
for promotion to gimple registers. We'll transform their uses
@@ -7121,7 +7135,8 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
break;
case COMPOUND_LITERAL_EXPR:
- ret = gimplify_compound_literal_expr (expr_p, pre_p, fallback);
+ ret = gimplify_compound_literal_expr (expr_p, pre_p,
+ gimple_test_f, fallback);
break;
case MODIFY_EXPR: