https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81148
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> --- It should've been --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -874,9 +874,24 @@ split_tree (location_t loc, tree in, tree type, enum tree_code code, } if (var) { - /* Convert to TYPE before negating. */ - var = fold_convert_loc (loc, type, var); - var = negate_expr (var); + if ((*litp == NULL_TREE + && *conp == NULL_TREE + && *minus_litp == NULL_TREE) + || !INTEGRAL_TYPE_P (type) + || TYPE_OVERFLOW_WRAPS (type)) + { + /* Convert to TYPE before negating. */ + var = fold_convert_loc (loc, type, var); + var = negate_expr (var); + } + else + { + /* Go back to blank slate. */ + var = in; + *conp = NULL_TREE; + *litp = NULL_TREE; + *minus_litp = NULL_TREE; + } } }