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

> 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 

```
     /* 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?

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

Reply via email to