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

--- Comment #3 from Kael Franco <kaelfandrew at gmail dot com> ---
(In reply to Drea Pinski from comment #2)
> I think we should do the opposite way around and convert `(type)(a == (CST +
> 1))` into `a+CST` instead. Adding is almost always simplier than comparsion.

/* (type)([0,1]@a != 0) -> (type)a
   (type)([0,1]@a == 1) -> (type)a
   (type)([0,1]@a == 0) -> a ^ 1
   (type)([0,1]@a != 1) -> a ^ 1.  */
(for eqne (eq ne)
 (simplify
  (convert (eqne zero_one_valued_p@0 INTEGER_CST@1))

This PR seems to be general version of above match pattern.

(type) ([CST,CST + 1]a == CST) -> (a - CST) ^ 1
(type) ([CST,CST + 1]a != CST) -> a - CST

Reply via email to