https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88784

--- Comment #13 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 24 May 2019, glisse at gcc dot gnu.org wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88784
> 
> --- Comment #12 from Marc Glisse <glisse at gcc dot gnu.org> ---
> (In reply to Qi Feng from comment #11)
> > I tried 2 patterns for the following test
> > 
> >   /* 1. x >  y  &&  x != 0     -->     x > y  */
> >   /* 2. y <  x  &&  x != 0     -->     y < x  */
> >   /* 3. x != 0  &&  x >  y     -->     x > y  */
> >   /* 4. x != 0  &&  y <  x     -->     y < x  */
> > 
> >   _Bool f1 (unsigned x, unsigned y)
> >   {
> >     return x >  y  &&  x != 0;
> >   }
> > 
> >   _Bool f2 (unsigned x, unsigned y)
> >   {
> >     return y <  x  &&  x != 0;
> >   }
> > 
> >   _Bool f3 (unsigned x, unsigned y)
> >   {
> >     return x != 0  &&  x >  y;
> >   }
> > 
> >   _Bool f4 (unsigned x, unsigned y)
> >   {
> >     return x != 0  &&  y <  x;
> >   }
> > 
> > The first one is
> > 
> >   (for and (truth_and bit_and)
> >     (simplify
> >      (and:c (gt:c@2 @0 @1) (ne @0 integer_zerop))
> >       (if (INTEGRAL_TYPE_P (TREE_TYPE(@0)) && TYPE_UNSIGNED (TREE_TYPE(@0))
> >            && INTEGRAL_TYPE_P (TREE_TYPE(@1)) && TYPE_UNSIGNED
> > (TREE_TYPE(@1)))
> >        @2)))
> > 
> > The transformations did not happen as I checked the dump files of
> > -fdump-tree-{original,optimized}.
> 
> It isn't supposed to be done in original anyway. It does work in optimized
> (even forwprop1) for me. Did you forget to pass -O? Did you look at some old
> dump file?
> 
> (I think you could use ANY_INTEGRAL_TYPE_P, this seems valid for vectors)

I would have expected fold to first change the TRUTH_ANDIF to a
TRUTH_AND and then your pattern match.  But maybe I misremember
that we have such transformation for cases where the 2nd operand
doesn't have side-effects.

While genmatch inserts checks for and rejects operands with side-effects
I still wouldn't use truth_andif here.

As Marc says, expecting the transform in .original is probably
premature.  OTOH whether it is applicable on GIMPLE in the end might
depend on LOGICAL_OP_NON_SHORT_CIRCUIT and BRANCH_COST.

Reply via email to