This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][5/n] Remove GENERIC stmt combining from SCCVN


On Sat, 27 Jun 2015, Marc Glisse wrote:

> On Fri, 26 Jun 2015, Richard Biener wrote:
> 
> > + /* Equality compare simplifications from fold_binary  */
> > + (for cmp (eq ne)
> > +
> > +  /* If we have (A | C) == D where C & ~D != 0, convert this into 0.
> > +     Similarly for NE_EXPR.  */
> > +  (simplify
> > +   (cmp (convert?@3 (bit_ior @0 INTEGER_CST@1)) INTEGER_CST@2)
> > +   (if (tree_nop_conversion_p (TREE_TYPE (@3), TREE_TYPE (@0))
> > +        && wi::bit_and_not (@1, @2) != 0)
> > +    { constant_boolean_node (cmp == NE_EXPR, type); }))
> > +
> > +  /* (X ^ Y) == 0 becomes X == Y, and (X ^ Y) != 0 becomes X != Y.  */
> > +  (simplify
> > +   (cmp (bit_xor @0 @1) integer_zerop)
> > +   (cmp @0 @1))
> > +
> > +  /* (X ^ Y) == Y becomes X == 0.
> > +     Likewise (X ^ Y) == X becomes Y == 0.  */
> > +  (simplify
> > +   (cmp (bit_xor:c @0 @1) @0)
> 
> Don't you need cmp:c for this one? The transformation still somehow happens
> through forward_propagate_into_comparison, but it looks like an accident.

Yeah, I think it canonicalizes operand order (and uses the GENERIC
folding path).

I'm testing a patch changing the above to cmp:c.

> > +   (cmp @1 { build_zero_cst (TREE_TYPE (@1)); }))
> > +
> > +  /* (X ^ C1) op C2 can be rewritten as X op (C1 ^ C2).  */
> > +  (simplify
> > +   (cmp (convert?@3 (bit_xor @0 INTEGER_CST@1)) INTEGER_CST@2)
> > +   (if (tree_nop_conversion_p (TREE_TYPE (@3), TREE_TYPE (@0)))
> > +    (cmp @0 (bit_xor @1 (convert @2))))))
> 
> I guess we'll have to generalize this to vectors at some point...

True - I'm trying to move patterns 1:1 leaving improvements to followups

Thanks,
Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]