This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/80281] [5/6/7 Regression] Wrong constant folding
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 03 Apr 2017 07:45:41 +0000
- Subject: [Bug tree-optimization/80281] [5/6/7 Regression] Wrong constant folding
- Auto-submitted: auto-generated
- References: <bug-80281-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80281
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
/* A + (-B) -> A - B */
(simplify
(plus:c (convert1? @0) (convert2? (negate @1)))
/* Apply STRIP_NOPS on @0 and the negate. */
(if (tree_nop_conversion_p (type, TREE_TYPE (@0))
&& tree_nop_conversion_p (type, TREE_TYPE (@1))
&& !TYPE_OVERFLOW_SANITIZED (type))
(minus (convert @0) (convert @1))))
(gdb) p debug_generic_expr (captures[1])
(unsigned int) b
$9 = void
(gdb) p debug_generic_expr (captures[0])
c
so that results in c + (int)-(unsigned)b -> c - (int)(unsigned)b. Similar
code was in tree-ssa-forwprop.c before but that didn't trigger for the testcase
because we first constant propagated.
> gcc-4.8 t.c -O2 -fdisable-tree-ccp1
> ./a.out
Aborted (core dumped)
so probably latent since quite some time.