diff options
author | Michael Matz <matz@suse.de> | 2012-06-15 14:46:36 +0000 |
---|---|---|
committer | Michael Matz <matz@gcc.gnu.org> | 2012-06-15 14:46:36 +0000 |
commit | 4c53d18336abbbc580fb0c6a51beed7d2776a209 (patch) | |
tree | 52ddf82808940117f11925d8592a4fa676566921 /gcc | |
parent | 6da8be895c345e90cec9a70fdeb38111fc48a880 (diff) | |
download | gcc-4c53d18336abbbc580fb0c6a51beed7d2776a209.zip gcc-4c53d18336abbbc580fb0c6a51beed7d2776a209.tar.gz gcc-4c53d18336abbbc580fb0c6a51beed7d2776a209.tar.bz2 |
gimplify.c (gimplify_compound_literal_expr): Take gimple_test_f argument...
* 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.
From-SVN: r188665
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/gimplify.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vector-4.c | 14 |
4 files changed, 40 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7f21827..ebb64a7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2012-06-15 Michael Matz <matz@suse.de> + * gimplify.c (gimplify_compound_literal_expr): Take gimple_test_f + argument, don't emit assign statement if value is directly usable. + (gimplify_expr): Adjust. + +2012-06-15 Michael Matz <matz@suse.de> + * gimplify.c (gimplify_modify_expr): Fold generated statements. * gimple-fold.c (can_refer_decl_in_current_unit_p): Check flag_ltrans. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index c59e754..9bf4ead 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: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 44215ff..8678626 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2012-06-15 Michael Matz <matz@suse.de> + * gcc.dg/tree-ssa/vector-4.c: New test. + +2012-06-15 Michael Matz <matz@suse.de> + * gcc.dg/debug/dwarf2/inline3.c: Adjust. * gcc.dg/tree-ssa/foldstring-1.c: Adjust. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vector-4.c b/gcc/testsuite/gcc.dg/tree-ssa/vector-4.c new file mode 100644 index 0000000..bfef25f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vector-4.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-w -O1 -fdump-tree-gimple" } */ + +typedef int v4si __attribute__ ((vector_size (16))); + +v4si vs (v4si a, v4si b) +{ + return __builtin_shuffle (a, b, (v4si) {0, 4, 1, 5}); +} + +/* The compound literal should be placed directly in the vec_perm. */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR <a, b, { 0, 4, 1, 5 }>;" 1 "gimple"} } */ + +/* { dg-final { cleanup-tree-dump "gimple" } } */ |