This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR28187, endless looping in VRP
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 6 Jul 2006 08:42:07 +0200 (CEST)
- Subject: [PATCH] Fix PR28187, endless looping in VRP
We do endless looping in VRP due to the fact that update_value_range
relies on pointer equivalence for testing if last_7 + -1 == last_7 + -1,
which is of course bogus. Fixed by using operand_equal_p.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
Ok for 4.1 and trunk?
(operand_equal_p doesn't have a shortcut for arg0 == arg1, nor for
arg0 == NULL_TREE or arg1 == NULL_TREE (which I wouldn't like) - the
former may be a good idea though and would simplify the patch a little?)
Thanks,
Richard.
:ADDPATCH middle-end:
2006-07-05 Richard Guenther <rguenther@suse.de>
PR tree-optimization/28187
* tree-vrp.c (update_value_range): Use operand_equal_p
to compare old and new max and min values.
* gcc.dg/pr28187.c: New testcase.
Index: tree-vrp.c
===================================================================
*** tree-vrp.c (revision 115200)
--- tree-vrp.c (working copy)
*************** update_value_range (tree var, value_rang
*** 300,307 ****
/* Update the value range, if necessary. */
old_vr = get_value_range (var);
is_new = old_vr->type != new_vr->type
! || old_vr->min != new_vr->min
! || old_vr->max != new_vr->max
|| (old_vr->equiv == NULL && new_vr->equiv)
|| (old_vr->equiv && new_vr->equiv == NULL)
|| (!bitmap_equal_p (old_vr->equiv, new_vr->equiv));
--- 300,313 ----
/* Update the value range, if necessary. */
old_vr = get_value_range (var);
is_new = old_vr->type != new_vr->type
! || (old_vr->min == NULL && new_vr->min)
! || (old_vr->min && new_vr->min == NULL)
! || (old_vr->max == NULL && new_vr->max)
! || (old_vr->max && new_vr->max == NULL)
! || (old_vr->min && new_vr->min
! && !operand_equal_p (old_vr->min, new_vr->min, 0))
! || (old_vr->max && new_vr->max
! && !operand_equal_p (old_vr->max, new_vr->max, 0))
|| (old_vr->equiv == NULL && new_vr->equiv)
|| (old_vr->equiv && new_vr->equiv == NULL)
|| (!bitmap_equal_p (old_vr->equiv, new_vr->equiv));
Index: testsuite/gcc.dg/pr28187.c
===================================================================
*** testsuite/gcc.dg/pr28187.c (revision 0)
--- testsuite/gcc.dg/pr28187.c (revision 0)
***************
*** 0 ****
--- 1,22 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O -ftree-vrp -fwrapv" } */
+
+ extern void bar(int);
+ void checkgroups(int last, int verbose)
+ {
+ int window = 0;
+ int outstanding = 0;
+ while (window < last || outstanding) {
+ while (outstanding < 47 && window < last) {
+ if (window < last) {
+ outstanding++;
+ if (verbose)
+ bar(window);
+ bar(window++);
+ }
+ }
+ if (outstanding > 0)
+ bar(0);
+ }
+ }
+