https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118976
avieira at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |avieira at gcc dot gnu.org --- Comment #13 from avieira at gcc dot gnu.org --- Looked a bit into this and fre4 takes: _30 = { POLY_INT_CST [4, 4], POLY_INT_CST [5, 4], POLY_INT_CST [6, 4], ... }; ... vect__3.13_46 = ~_30; and simplifies that ~_30 to a constant: { POLY_INT_CST [-4, -4], POLY_INT_CST [-5, -4], POLY_INT_CST [-6, -4], ... } Which seems wrong to me, as ~(4) = -5, not -4 looking at const_binop in fold-const.cc I see: case BIT_NOT_EXPR: if (TREE_CODE (arg0) == INTEGER_CST) return fold_not_const (arg0, type); else if (POLY_INT_CST_P (arg0)) return wide_int_to_tree (type, -poly_int_cst_value (arg0)); /* Perform BIT_NOT_EXPR on each element individually. */ else if (TREE_CODE (arg0) == VECTOR_CST) ... the VECTOR_CST just goes over the elements in the VECTOR_CST and calls this recursively, making the change: --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -1964,7 +1964,7 @@ const_unop (enum tree_code code, tree type, tree arg0) if (TREE_CODE (arg0) == INTEGER_CST) return fold_not_const (arg0, type); else if (POLY_INT_CST_P (arg0)) - return wide_int_to_tree (type, -poly_int_cst_value (arg0)); + return wide_int_to_tree (type, ~poly_int_cst_value (arg0)); /* Perform BIT_NOT_EXPR on each element individually. */ else if (TREE_CODE (arg0) == VECTOR_CST) { fixes it for me. I'm going on holidays tomorrow, so I'll leave this for someone with a bit more time to pick up. Richard S it seems to have been your change in: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=36fd64086542ed734aded849304723218fa4d6fd so I'll wait for others to confirm my thinking here, I always get nervous around bit fiddling ;)