re PR tree-optimization/53465 (wrong code with -O1 -ftree-vrp)

PR tree-optimization/53465
	* tree-vrp.c (extract_range_from_cond_expr): First copy_value_range
	vr0 into *vr, then vrp_meet that.
	(vrp_meet): If one vr type is VR_UNDEFINED, ensure the result doesn't
	have any equivalences.
	(vrp_visit_phi_node): Call copy_value_range instead of vrp_meet the
	first time.

	* gcc.c-torture/execute/pr53465.c: New test.

From-SVN: r187828
This commit is contained in:
Jakub Jelinek 2012-05-24 13:53:29 +02:00 committed by Jakub Jelinek
parent dc6121052c
commit 5a00618528
4 changed files with 58 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2012-05-24 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/53465
* tree-vrp.c (extract_range_from_cond_expr): First copy_value_range
vr0 into *vr, then vrp_meet that.
(vrp_meet): If one vr type is VR_UNDEFINED, ensure the result doesn't
have any equivalences.
(vrp_visit_phi_node): Call copy_value_range instead of vrp_meet the
first time.
2012-05-23 Eric Botcazou <ebotcazou@adacore.com>
* gimple.c (gimple_types_compatible_p_1) <ARRAY_TYPE>: Remove bogus

View File

@ -1,3 +1,8 @@
2012-05-24 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/53465
* gcc.c-torture/execute/pr53465.c: New test.
2012-05-23 Tobias Burnus <burnus@net-b.de>
PR fortran/53389

View File

@ -0,0 +1,30 @@
/* PR tree-optimization/53465 */
extern void abort ();
static const int a[] = { 1, 2 };
void
foo (const int *x, int y)
{
int i;
int b = 0;
int c;
for (i = 0; i < y; i++)
{
int d = x[i];
if (d == 0)
break;
if (b && d <= c)
abort ();
c = d;
b = 1;
}
}
int
main ()
{
foo (a, 2);
return 0;
}

View File

@ -3247,8 +3247,8 @@ extract_range_from_cond_expr (value_range_t *vr, gimple stmt)
set_value_range_to_varying (&vr1);
/* The resulting value range is the union of the operand ranges */
vrp_meet (&vr0, &vr1);
copy_value_range (vr, &vr0);
vrp_meet (vr, &vr1);
}
@ -6447,13 +6447,17 @@ vrp_meet (value_range_t *vr0, value_range_t *vr1)
{
if (vr0->type == VR_UNDEFINED)
{
copy_value_range (vr0, vr1);
/* Drop equivalences. See PR53465. */
set_value_range (vr0, vr1->type, vr1->min, vr1->max, NULL);
return;
}
if (vr1->type == VR_UNDEFINED)
{
/* Nothing to do. VR0 already has the resulting range. */
/* VR0 already has the resulting range, just drop equivalences.
See PR53465. */
if (vr0->equiv)
bitmap_clear (vr0->equiv);
return;
}
@ -6595,6 +6599,7 @@ vrp_visit_phi_node (gimple phi)
tree lhs = PHI_RESULT (phi);
value_range_t *lhs_vr = get_value_range (lhs);
value_range_t vr_result = { VR_UNDEFINED, NULL_TREE, NULL_TREE, NULL };
bool first = true;
int edges, old_edges;
struct loop *l;
@ -6651,7 +6656,11 @@ vrp_visit_phi_node (gimple phi)
fprintf (dump_file, "\n");
}
vrp_meet (&vr_result, &vr_arg);
if (first)
copy_value_range (&vr_result, &vr_arg);
else
vrp_meet (&vr_result, &vr_arg);
first = false;
if (vr_result.type == VR_VARYING)
break;