]> gcc.gnu.org Git - gcc.git/commitdiff
fold-const.c (operand_equal_p): Add code matching empty constructors.
authorJan Hubicka <hubicka@ucw.cz>
Wed, 21 Oct 2015 21:12:05 +0000 (23:12 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Wed, 21 Oct 2015 21:12:05 +0000 (21:12 +0000)
* 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

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/operand-equal-1.c [new file with mode: 0644]

index 457c3385f8754b34657f212e223d2c590c68f754..38ae32110db492b6fda6db6d7ab925d02d9682a3 100644 (file)
@@ -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
index b7874a08c0b62acab3762d085de13f223557eb03..602ea240cb4b148442890fff3b0358556f87d4ff 100644 (file)
@@ -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;
       }
index 9c76295c91689b74f21d6103d79448bce244912a..4637ae747e2059a2e273f7582128879ef4c5a6a3 100644 (file)
@@ -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 (file)
index 0000000..09e9302
--- /dev/null
@@ -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"} } */
This page took 0.137813 seconds and 5 git commands to generate.