* fold-const.c (operand_equal_p): Add code matching empty
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Oct 2015 21:12:05 +0000 (21:12 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 21 Oct 2015 21:12:05 +0000 (21:12 +0000)
constructors.
* gcc.dg/tree-ssa/operand-equal-1.c: Verify that empty constructors
are matched.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229147 138bc75d-0d04-0410-961f-82ee72b054a4

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 457c338..38ae321 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 b7874a0..602ea24 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 9c76295..4637ae7 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"} } */