This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/71608] Wrong constant folding
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 21 Jun 2016 15:27:34 +0000
- Subject: [Bug tree-optimization/71608] Wrong constant folding
- Auto-submitted: auto-generated
- References: <bug-71608-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71608
--- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> ---
negate_expr_p, for MULT_EXPR, has:
/* INT_MIN/n * n doesn't overflow while negating one operand it does
if n is a power of two. */
if (INTEGRAL_TYPE_P (TREE_TYPE (t))
&& ! TYPE_OVERFLOW_WRAPS (TREE_TYPE (t))
&& ! ((TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST
&& ! integer_pow2p (TREE_OPERAND (t, 0)))
|| (TREE_CODE (TREE_OPERAND (t, 1)) == INTEGER_CST
&& ! integer_pow2p (TREE_OPERAND (t, 1)))))
break;
It handles INT_MIN/n * n where n is a power of 2 but not -(INT_MIN/n) * -n.
I am not convinced by the way fold_negate_expr handles this either.