https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92282
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2019-10-30 Component|tree-optimization |middle-end Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- This is fold-const.c split_tree/associate_trees at work. else if (TREE_CODE (in) == BIT_NOT_EXPR && code == PLUS_EXPR) { /* -1 - X is folded to ~X, undo that here. Do _not_ do this when IN is constant. */ *litp = build_minus_one_cst (type); *minus_varp = TREE_OPERAND (in, 0); In the end we want to help optimizing ~A - 1. Might be possible to reject the specific simplification (if no constant was eliminated or the constant got "large") in the caller of associate_trees.