aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c2
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/ftrapv-3.c16
4 files changed, 26 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f3b7c11..7a7c0ec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2011-07-07 Richard Guenther <rguenther@suse.de>
+ * fold-const.c (fold_unary_loc): Do not strip sign-changes
+ for NEGATE_EXPR.
+
+2011-07-07 Richard Guenther <rguenther@suse.de>
+
* tree-vrp.c (simplify_conversion_using_ranges): New function.
(simplify_stmt_using_ranges): Call it.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index e48aae9..44a8b6f 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7561,7 +7561,7 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
if (arg0)
{
if (CONVERT_EXPR_CODE_P (code)
- || code == FLOAT_EXPR || code == ABS_EXPR)
+ || code == FLOAT_EXPR || code == ABS_EXPR || code == NEGATE_EXPR)
{
/* Don't use STRIP_NOPS, because signedness of argument type
matters. */
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 910a333..1800d48 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,9 @@
2011-07-07 Richard Guenther <rguenther@suse.de>
+ * gcc.dg/ftrapv-3.c: New testcase.
+
+2011-07-07 Richard Guenther <rguenther@suse.de>
+
* gcc.dg/tree-ssa/vrp58.c: New testcase.
* gcc.dg/tree-ssa/scev-cast.c: Adjust.
diff --git a/gcc/testsuite/gcc.dg/ftrapv-3.c b/gcc/testsuite/gcc.dg/ftrapv-3.c
new file mode 100644
index 0000000..e23059a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ftrapv-3.c
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+/* { dg-options "-ftrapv" } */
+
+extern void abort (void);
+unsigned long
+foo (long i, long j)
+{
+ /* We may not fold this to (unsigned long)(i * j). */
+ return -(unsigned long)(i * -j);
+}
+int main()
+{
+ if (foo (-__LONG_MAX__ - 1, -1) != -(unsigned long)(-__LONG_MAX__ - 1))
+ abort ();
+ return 0;
+}