This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[RFH] negate_expr_p bug?
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc at gcc dot gnu dot org
- Cc: roger at eyesopen dot com
- Date: Mon, 3 Apr 2006 12:08:21 +0200 (CEST)
- Subject: [RFH] negate_expr_p bug?
negate_expr_p currently contains
switch (TREE_CODE (t))
{
case INTEGER_CST:
if (TYPE_UNSIGNED (type) || ! flag_trapv)
return true;
/* Check that -CST will not overflow type. */
return may_negate_without_overflow_p (t);
where it looks bogus to simply return true for signed types but
unset flag_trapv. This was introduced by Roger
@@ -822,8 +853,8 @@ negate_expr_p (tree t)
switch (TREE_CODE (t))
{
case INTEGER_CST:
- if (TREE_UNSIGNED (type))
- return false;
+ if (TREE_UNSIGNED (type) || ! flag_trapv)
+ return true;
/* Check that -CST will not overflow type. */
prec = TYPE_PRECISION (type);
with r72381
2003-10-11 Roger Sayle <roger@eyesopen.com>
+ (negate_expr_p): We can always negate integer constants unless
+ we honor -ftrapv and the signed type would overflow.
which is bogus as it should read || (!flag_trapv && flag_wrapv) - no?
I hit this with a patch to fold A +- CST to A -+ CST for negative CST,
which tells me it is ok to negate -INT_MAX.
Fix outlined above ok for mainline?
Thanks,
Richard.