aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20170429-1.c24
-rw-r--r--gcc/tree-vrp.c30
4 files changed, 65 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6b17e9a..de76f8a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2017-04-19 Eric Botcazou <ebotcazou@adacore.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/80426
+ * tree-vrp.c (extract_range_from_binary_expr_1): For an additive
+ operation on symbolic operands, also compute the overflow for the
+ invariant part when the operation degenerates into a negation.
+
2017-04-19 Jakub Jelinek <jakub@redhat.com>
PR debug/80461
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 048541d..7c306a6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-19 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR tree-optimization/80426
+ * gcc.c-torture/execute/20170419-1.c: New test.
+
2017-04-19 Jakub Jelinek <jakub@redhat.com>
PR debug/80461
diff --git a/gcc/testsuite/gcc.c-torture/execute/20170429-1.c b/gcc/testsuite/gcc.c-torture/execute/20170429-1.c
new file mode 100644
index 0000000..f59dbc7
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20170429-1.c
@@ -0,0 +1,24 @@
+/* PR tree-optimization/80426 */
+/* Testcase by <ishiura-compiler@ml.kwansei.ac.jp> */
+
+#define INT_MAX 0x7fffffff
+#define INT_MIN (-INT_MAX-1)
+
+int x;
+
+int main (void)
+{
+ volatile int a = 0;
+ volatile int b = -INT_MAX;
+ int j;
+
+ for(j = 0; j < 18; j += 1) {
+ x = ( (a == 0) != (b - (int)(INT_MIN) ) );
+ }
+
+ if (x != 0)
+ __builtin_abort ();
+
+ return 0;
+}
+
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 6d802de..697cd88 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -2461,7 +2461,20 @@ extract_range_from_binary_expr_1 (value_range *vr,
else if (min_op0)
wmin = min_op0;
else if (min_op1)
- wmin = minus_p ? wi::neg (min_op1) : min_op1;
+ {
+ if (minus_p)
+ {
+ wmin = wi::neg (min_op1);
+
+ /* Check for overflow. */
+ if (sgn == SIGNED && wi::neg_p (min_op1) && wi::neg_p (wmin))
+ min_ovf = 1;
+ else if (sgn == UNSIGNED && wi::ne_p (min_op1, 0))
+ min_ovf = -1;
+ }
+ else
+ wmin = min_op1;
+ }
else
wmin = wi::shwi (0, prec);
@@ -2489,7 +2502,20 @@ extract_range_from_binary_expr_1 (value_range *vr,
else if (max_op0)
wmax = max_op0;
else if (max_op1)
- wmax = minus_p ? wi::neg (max_op1) : max_op1;
+ {
+ if (minus_p)
+ {
+ wmax = wi::neg (max_op1);
+
+ /* Check for overflow. */
+ if (sgn == SIGNED && wi::neg_p (max_op1) && wi::neg_p (wmax))
+ max_ovf = 1;
+ else if (sgn == UNSIGNED && wi::ne_p (max_op1, 0))
+ max_ovf = -1;
+ }
+ else
+ wmax = max_op1;
+ }
else
wmax = wi::shwi (0, prec);