+2005-12-22 Kazu Hirata <kazu@codesourcery.com>
+
+ PR tree-optimization/23518
+ * fold-const.c (make_range): Don't move a constant to the
+ other side of the comparison if the type is signed and -fwrapv
+ is given.
+
2005-12-22 Kazu Hirata <kazu@codesourcery.com>
* tree-vrp.c (extract_range_from_binary_expr): Clean up uses
if (TREE_CODE (arg1) != INTEGER_CST)
break;
+ /* If flag_wrapv and ARG0_TYPE is signed, then we cannot
+ move a constant to the other side. */
+ if (flag_wrapv && !TYPE_UNSIGNED (arg0_type))
+ break;
+
/* If EXP is signed, any overflow in the computation is undefined,
so we don't worry about it so long as our computations on
the bounds don't overflow. For unsigned, overflow is defined
+2005-12-22 Kazu Hirata <kazu@codesourcery.com>
+
+ PR tree-optimization/23518
+ * testsuite/gcc.dg/pr23518.c: New.
+
2005-12-21 Mike Stump <mrs@apple.com>
* gcc.dg/attr-weakref-1.c: Really skip on darwin.
--- /dev/null
+/* PR tree-optimization/23518.
+ make_range used to transform a + 1 < 0 into a < -1 even when a is
+ signed and -fwrapv is given. Make sure that no longer happens. */
+
+/* { dg-do run } */
+/* { dg-options "-O2 -fwrapv" } */
+
+#include <limits.h>
+
+extern void abort (void);
+extern void exit (int);
+
+int
+main (void)
+{
+ int a = INT_MAX;
+ if ((a < 0) || (a + 1 < 0))
+ exit (0);
+
+ abort ();
+}