On Wed, 28 Sep 2016, Joseph Myers wrote:

> On Wed, 28 Sep 2016, Richard Biener wrote:
> 
> > Index: gcc/testsuite/gcc.dg/pr55152.c
> > ===================================================================
> > --- gcc/testsuite/gcc.dg/pr55152.c  (revision 0)
> > +++ gcc/testsuite/gcc.dg/pr55152.c  (working copy)
> > @@ -0,0 +1,13 @@
> > +/* { dg-do compile } */
> > +/* { dg-options "-O -ffinite-math-only -fstrict-overflow 
> > -fdump-tree-optimized" } */
> > +
> > +double g (double a)
> > +{
> > +  return (a>=-a)?a:-a;
> 
> You should need -fno-signed-zeros for this (that is, for the 
> transformation to MAX_EXPR), not -ffinite-math-only.  For a == -0, that 
> function should return -0, but abs would produce +0.

This means that tree-ssa-phiopt.c has a bug:

static bool
minmax_replacement (basic_block cond_bb, basic_block middle_bb,
                    edge e0, edge e1, gimple *phi,
                    tree arg0, tree arg1)
{
...
  /* The optimization may be unsafe due to NaNs.  */
  if (HONOR_NANS (type))
    return false;

and it should check HONOR_SIGNED_ZEROS as well.

I'll fix that as a followup.

Thanks,
Richard.

Reply via email to