https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103530
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- gcc_checking_assert (TREE_CODE (TREE_TYPE (lhs)) == BOOLEAN_TYPE); This assert is incorrect because useless_type_conversion_p has the following code: /* If both the inner and outer types are integral types, then the conversion is not necessary if they have the same mode and signedness and precision, and both or neither are boolean. */ if (INTEGRAL_TYPE_P (inner_type) && INTEGRAL_TYPE_P (outer_type)) { /* Preserve changes in signedness or precision. */ if (TYPE_UNSIGNED (inner_type) != TYPE_UNSIGNED (outer_type) || TYPE_PRECISION (inner_type) != TYPE_PRECISION (outer_type)) return false; /* Preserve conversions to/from BOOLEAN_TYPE if types are not of precision one. */ if (((TREE_CODE (inner_type) == BOOLEAN_TYPE) != (TREE_CODE (outer_type) == BOOLEAN_TYPE)) && TYPE_PRECISION (outer_type) != 1) return false; /* We don't need to preserve changes in the types minimum or maximum value in general as these do not generate code unless the types precisions are different. */ return true; } Which means if the precision is 1 of the integer type (and boolean is also prevision of 1), then the cast between BOOLEAN_TYPE and that integer type will be removed.