Commit c81a5aec by Jakub Jelinek Committed by Jakub Jelinek

re PR tree-optimization/86231 (vrp_meet causes wrong-code)

	PR tree-optimization/86231
	* tree-vrp.c (union_ranges): For (  [  )  ] or (   )[   ] range and
	anti-range don't overwrite *vr0min before using it to compute *vr0max.

	* gcc.dg/tree-ssa/vrp119.c: New test.
	* gcc.c-torture/execute/pr86231.c: New test.

From-SVN: r261805
parent 60f02f90
2018-06-20 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/86231
* tree-vrp.c (union_ranges): For ( [ ) ] or ( )[ ] range and
anti-range don't overwrite *vr0min before using it to compute *vr0max.
2018-06-20 Tom de Vries <tdevries@suse.de>
PR tree-optimization/86097
......
2018-06-20 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/86231
* gcc.dg/tree-ssa/vrp119.c: New test.
* gcc.c-torture/execute/pr86231.c: New test.
2018-06-20 Tom de Vries <tdevries@suse.de>
PR tree-optimization/86097
......
/* PR tree-optimization/86231 */
#define ONE ((void *) 1)
#define TWO ((void *) 2)
__attribute__((noipa)) int
foo (void *p, int x)
{
if (p == ONE) return 0;
if (!p)
p = x ? TWO : ONE;
return p == ONE ? 0 : 1;
}
int v[8];
int
main ()
{
if (foo ((void *) 0, 0) != 0
|| foo ((void *) 0, 1) != 1
|| foo (ONE, 0) != 0
|| foo (ONE, 1) != 0
|| foo (TWO, 0) != 1
|| foo (TWO, 1) != 1
|| foo (&v[7], 0) != 1
|| foo (&v[7], 1) != 1)
__builtin_abort ();
return 0;
}
/* PR tree-optimization/86231 */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1" } */
/* { dg-final { scan-tree-dump-not "link_error" "vrp1" } } */
int bar (int);
void link_error (void);
int
foo (int x, int y, int z)
{
if (x < 4 || x > 8) __builtin_unreachable ();
if (y >= 2 && y <= 6) __builtin_unreachable ();
/* x is [4, 8], y is ~[2, 6], resulting range of e should be ~[2, 3]. */
int e = (z ? x : y);
bar (bar (bar (bar (bar (bar (bar (bar (bar (bar (bar (bar (e))))))))))));
if (e == 2 || e == 3)
link_error ();
return e;
}
......@@ -5922,9 +5922,9 @@ union_ranges (enum value_range_type *vr0type,
if (TREE_CODE (*vr0min) == INTEGER_CST)
{
*vr0type = vr1type;
*vr0min = vr1min;
*vr0max = int_const_binop (MINUS_EXPR, *vr0min,
build_int_cst (TREE_TYPE (*vr0min), 1));
*vr0min = vr1min;
}
else
goto give_up;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment