@azoff wrote in 
https://forge.sourceware.org/gcc/gcc/pulls/193#issuecomment-6746:

> @pinskia wrote in #193 (comment):
> 
> > So can you generalize it slightly to instead of zero be all constants. Like 
> > (cond (eq @0 CONSTANT_CLASS@1) @0 @1).
> 
> I tried a few different things and ended up with
> 
> ```text
>      /* A == CST ? A : CST -> CST.  */
>        (simplify
>         (cnd (eq:c @0 @1) @2 @1)
>         (if (ANY_INTEGRAL_TYPE_P (type)
>              && CONSTANT_CLASS_P (@1)
>              && bitwise_equal_p (@0, @2))
>          @1))
>       
>        /* A != CST ? CST : A -> CST.  */
>        (simplify
>         (cnd (ne:c @0 @1) @1 @2)
>         (if (ANY_INTEGRAL_TYPE_P (type)
>              && CONSTANT_CLASS_P (@1)
>              && bitwise_equal_p (@0, @2))
>          @1)))
> ```
> 
> Is this what you were thinking of?

Yes but I dont think you need the :c and on the ne/eq as constant class should 
always be last always. Though you might need a convert too. 

--
https://forge.sourceware.org/gcc/gcc/pulls/193#issuecomment-6747

Reply via email to