https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80362
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- 10205 /* Convert -A / -B to A / B when the type is signed and overflow is 10206 undefined. */ 10207 if ((!INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type)) 10208 && TREE_CODE (arg0) == NEGATE_EXPR 10209 && negate_expr_p (op1)) 10210 { where op1 is 3. We're folding (signed char) -(unsigned char) var_1 / 3 and arg0 is - (unsigned char) var_1 but _unsigned_. Trivial fix: Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 246797) +++ gcc/fold-const.c (working copy) @@ -10205,7 +10205,7 @@ fold_binary_loc (location_t loc, /* Convert -A / -B to A / B when the type is signed and overflow is undefined. */ if ((!INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_UNDEFINED (type)) - && TREE_CODE (arg0) == NEGATE_EXPR + && TREE_CODE (op0) == NEGATE_EXPR && negate_expr_p (op1)) { if (INTEGRAL_TYPE_P (type))