diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2015-10-21 23:12:05 +0200 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2015-10-21 21:12:05 +0000 |
commit | 1567db2f02e005b7a3349aedf0afb37c36260beb (patch) | |
tree | d49fbba1fc1f57ae6b2bf82b7ae886bec54401ad /gcc | |
parent | c26065cc38586f9d014b0f04a54dfa0e52c23189 (diff) | |
download | gcc-1567db2f02e005b7a3349aedf0afb37c36260beb.zip gcc-1567db2f02e005b7a3349aedf0afb37c36260beb.tar.gz gcc-1567db2f02e005b7a3349aedf0afb37c36260beb.tar.bz2 |
fold-const.c (operand_equal_p): Add code matching empty constructors.
* fold-const.c (operand_equal_p): Add code matching empty
constructors.
* gcc.dg/tree-ssa/operand-equal-1.c: Verify that empty constructors
are matched.
From-SVN: r229147
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/operand-equal-1.c | 8 |
4 files changed, 24 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 457c338..38ae321 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-10-11 Jan Hubicka <hubicka@ucw.cz> + + * fold-const.c (operand_equal_p): Add code matching empty + constructors. + 2015-10-21 Eric Botcazou <ebotcazou@adacore.com> * tree.def (CEIL_DIV_EXPR, FLOOR_DIV_EXPR, ROUND_DIV_EXPR): Tweak diff --git a/gcc/fold-const.c b/gcc/fold-const.c index b7874a0..602ea24 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -2891,6 +2891,11 @@ operand_equal_p (const_tree arg0, const_tree arg1, unsigned int flags) return operand_equal_p (TREE_OPERAND (arg0, 0), TREE_OPERAND (arg1, 0), flags | OEP_ADDRESS_OF | OEP_CONSTANT_ADDRESS_OF); + case CONSTRUCTOR: + /* In GIMPLE empty constructors are allowed in initializers of + aggregates. */ + return (!vec_safe_length (CONSTRUCTOR_ELTS (arg0)) + && !vec_safe_length (CONSTRUCTOR_ELTS (arg1))); default: break; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9c76295..4637ae7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-10-11 Jan Hubicka <hubicka@ucw.cz> + + * gcc.dg/tree-ssa/operand-equal-1.c: Verify that empty constructors + are matched. + 2015-10-21 Richard Sandiford <richard.sandiford@arm.com> * gcc.dg/lto/20110201-1_0.c: Restrict to sqrt_insn targets. @@ -21,6 +26,7 @@ 2015-10-21 Marek Polacek <polacek@redhat.com> + PR c/68024 * gcc.dg/pr68024.c: New test. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/operand-equal-1.c b/gcc/testsuite/gcc.dg/tree-ssa/operand-equal-1.c new file mode 100644 index 0000000..09e9302 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/operand-equal-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-pre" } */ +struct a {int a,b;}; +struct a ret(int val) +{ + return val? (struct a){} : (struct a){}; +} +/* { dg-final { scan-tree-dump-not "if " "pre"} } */ |