On Thu, 3 Nov 2016, Prathamesh Kulkarni wrote:

> Hi Richard,
> The attached patch tries to fix PR35691, by adding the following two
> transforms to match.pd:
> (x == 0 && y == 0) -> (x | typeof(x)(y)) == 0.
> (x != 0 || y != 0) -> (x | typeof(x)(y)) != 0.
> 
> For GENERIC, the "and" operator is truth_andif_expr, and it seems for GIMPLE,
> it gets transformed to bit_and_expr
> so to match for both GENERIC and GIMPLE, I had to guard the for-stmt:
> 
> #if GENERIC
> (for op (truth_andif truth_orif)
> #elif GIMPLE
> (for op (bit_and bit_ior)
> #endif
> 
> Is that OK ?

As you are not removing the fold-const.c variant I'd say you should
simply not look for truth_* and only handle GIMPLE.  Note that we
have tree-ssa-ifcombine.c which should handle the variant with
control-flow (but I guess it does not and your patch wouldn't help
it either).

The transform would also work for vectors (element_precision for
the test but also a value-matching zero which should ensure the
same number of elements).

Richard.

Reply via email to