https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112738
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This is what I will be testing: ``` /* (nop_outer_cast)-(inner_cast)var -> -(outer_cast)(var) if var is smaller in precision. This is always safe for both doing the negative in signed or unsigned as the value for undefined will not show up. Note the outer cast cannot be a boolean type as the only valid values are 0,-1/1 (depending on the signedness of the boolean) and the negative is there to get the correct value. */ (simplify (convert (negate:s@1 (convert:s @0))) (if (INTEGRAL_TYPE_P (type) && tree_nop_conversion_p (type, TREE_TYPE (@1)) && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (@0)) && TREE_CODE (type) != BOOLEAN_TYPE) (negate (convert @0)))) ``` It even records on why boolean check is needed.