+2006-06-08 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/27116
+ * fold-const.c (negate_expr_p): We can negate BIT_NOT_EXPR
+ only, if overflow is defined and not trapping.
+ (negate_expr): Likewise.
+
2006-06-07 Zdenek Dvorak <dvorakz@suse.cz>
PR tree-optimization/27872
/* Check that -CST will not overflow type. */
return may_negate_without_overflow_p (t);
case BIT_NOT_EXPR:
- return INTEGRAL_TYPE_P (type);
+ return INTEGRAL_TYPE_P (type)
+ && (TYPE_UNSIGNED (type)
+ || (flag_wrapv && !flag_trapv));
case REAL_CST:
case NEGATE_EXPR:
{
/* Convert - (~A) to A + 1. */
case BIT_NOT_EXPR:
- if (INTEGRAL_TYPE_P (type))
+ if (INTEGRAL_TYPE_P (type)
+ && (TYPE_UNSIGNED (type)
+ || (flag_wrapv && !flag_trapv)))
return fold_build2 (PLUS_EXPR, type, TREE_OPERAND (t, 0),
build_int_cst (type, 1));
break;
+2006-06-08 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/27116
+ * gcc.dg/torture/pr27116.c: New testcase.
+ * gcc.dg/pr15785-1.c: Remove test for invalid transformation.
+
2006-06-07 Zdenek Dvorak <dvorakz@suse.cz>
PR rtl-optimization/26449
--- /dev/null
+/* { dg-do run } */
+
+extern void abort(void);
+
+int f(int a, int b)
+{
+ return (-1 - a) / (-b);
+}
+
+int main()
+{
+ if (f(__INT_MAX__, 2) != __INT_MAX__/2 + 1)
+ abort ();
+ return 0;
+}