re PR tree-optimization/80426 (wrong manipulation of range based on INT_MIN)
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. PR tree-optimization/80426 * gcc.c-torture/execute/20170419-1.c: New test. Co-Authored-By: Jakub Jelinek <jakub@redhat.com> From-SVN: r247007
This commit is contained in:
parent
52744dd73c
commit
fe1e7d0e9b
|
@ -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>
|
2017-04-19 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR debug/80461
|
PR debug/80461
|
||||||
|
|
|
@ -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>
|
2017-04-19 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR debug/80461
|
PR debug/80461
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
@ -2461,7 +2461,20 @@ extract_range_from_binary_expr_1 (value_range *vr,
|
||||||
else if (min_op0)
|
else if (min_op0)
|
||||||
wmin = min_op0;
|
wmin = min_op0;
|
||||||
else if (min_op1)
|
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
|
else
|
||||||
wmin = wi::shwi (0, prec);
|
wmin = wi::shwi (0, prec);
|
||||||
|
|
||||||
|
@ -2489,7 +2502,20 @@ extract_range_from_binary_expr_1 (value_range *vr,
|
||||||
else if (max_op0)
|
else if (max_op0)
|
||||||
wmax = max_op0;
|
wmax = max_op0;
|
||||||
else if (max_op1)
|
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
|
else
|
||||||
wmax = wi::shwi (0, prec);
|
wmax = wi::shwi (0, prec);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue