This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Handle CONSTRUCTOR in operand_equal_p
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Richard Biener <rguenther at suse dot de>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 23 Oct 2015 07:22:20 +0200
- Subject: Re: Handle CONSTRUCTOR in operand_equal_p
- Authentication-results: sourceware.org; auth=none
- References: <20151014162702 dot GD16672 at kam dot mff dot cuni dot cz> <ECF2C9BA-5973-4683-A681-2654CD579DCD at suse dot de> <20151014235509 dot GC16831 at kam dot mff dot cuni dot cz> <9FF55B7D-8DEC-45C4-8FDD-5AA0344B2B15 at suse dot de> <20151021190529 dot GB92763 at kam dot mff dot cuni dot cz> <alpine dot LSU dot 2 dot 11 dot 1510220929370 dot 16509 at zhemvz dot fhfr dot qr>
>
> But only via GENERIC folding I suppose. Yes, we don't value-number
> aggregates and generally PRE (and DOM via excessive jump-threading)
> is the only pass that remotely handles this kind of situation.
I actually think it is tail merging unifying the code, but I did not
really look too deep into it.
Honza
>
> code hoisting/sinking would maybe catch this but as this involves
> memory I'm not sure the implementation ontop of PRE that is stuck
> in some PR would catch it.
>
> Richard.
>
> > Honza
> >
> > * 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.
> >
> > Index: fold-const.c
> > ===================================================================
> > --- fold-const.c (revision 229133)
> > +++ fold-const.c (working copy)
> > @@ -2892,6 +2892,11 @@ operand_equal_p (const_tree arg0, const_
> > 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: testsuite/gcc.dg/tree-ssa/operand-equal-1.c
> > ===================================================================
> > --- testsuite/gcc.dg/tree-ssa/operand-equal-1.c (revision 0)
> > +++ testsuite/gcc.dg/tree-ssa/operand-equal-1.c (revision 0)
> > @@ -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"} } */
> >
> >
>
> --
> Richard Biener <rguenther@suse.de>
> SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nuernberg)