https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81097
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|mpolacek at gcc dot gnu.org |rguenth at gcc dot
gnu.org
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The negation is emitted from
#1 0x0000000000d6fb2f in split_tree (loc=2147483652,
in=<bit_not_expr 0x7ffff69f9920>, type=<integer_type 0x7ffff69e5348>,
code=PLUS_EXPR, conp=0x7fffffffc758, litp=0x7fffffffc750,
minus_litp=0x7fffffffc748, negate_p=0)
at /space/rguenther/src/svn/early-lto-debug/gcc/fold-const.c:858
858 var = negate_expr (TREE_OPERAND (in, 0));
(gdb) l
853 && code == PLUS_EXPR)
854 {
855 /* -X - 1 is folded to ~X, undo that here. Do _not_ do this
856 when IN is constant. */
857 *minus_litp = build_one_cst (TREE_TYPE (in));
858 var = negate_expr (TREE_OPERAND (in, 0));
when folding
(unsigned short) ~((signed short) a & (signed short) c)
+ (unsigned short) ~((signed short) b & (signed short) c)
so first-hand the error is obvious - we do not convert to 'type' before
negating.
But! I think that may be not enough to fix things (it fixes this testcase)
as we generally cannot fold ~x to -x - 1 for types with undefined overflow.