This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix PR 23141 and 23142
- From: Diego Novillo <dnovillo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sat, 15 Oct 2005 10:39:12 -0400
- Subject: Fix PR 23141 and 23142
I hate these bugs. There were two problems wrapped into one. As discussed
in http://gcc.gnu.org/ml/gcc/2005-09/msg00098.html, the logic to prevent
infinite iterations in vrp_visit_phi_node should only trigger when the
previous result and the new one are both VR_RANGEs.
That fixes a couple of Ada regressions and at the same time fixes a minor
pessimization. In most cases we were getting a new ~[val, val] anti-range
from vrp_meet that was being converted into VR_VARYING by this code.
However, this was also hiding a bug in vrp_meet in cases where we met a
VR_RANGE with a VR_ANTI_RANGE. If both ranges had equivalence sets,
instead of doing the intersection of equivalence sets we were just copying
one into the other. This was mis-compiling the C++ front end such that we
would get tons of syntax errors while compiling libstdc++.
Bootstrapped and tested x86, x86-64, ia64 and ppc64.
2005-10-15 Diego Novillo <dnovillo@redhat.com>
PR 23141
PR 23142
* tree-vrp.c (vrp_meet): Fix the intersection of equivalence
sets VR0->EQUIV and VR1->EQUIV when meeting a range and an
anti-range.
(vrp_visit_phi_node): Only prevent infinite iterations when
the previous result and the new result are both VR_RANGEs.
Index: tree-vrp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vrp.c,v
retrieving revision 2.62
diff -d -u -p -r2.62 tree-vrp.c
--- tree-vrp.c 4 Oct 2005 03:02:18 -0000 2.62
+++ tree-vrp.c 15 Oct 2005 14:26:11 -0000
@@ -3497,8 +3497,11 @@ vrp_meet (value_range_t *vr0, value_rang
&& !symbolic_range_p (vr1)
&& !value_ranges_intersect_p (vr0, vr1))
{
+ /* Copy most of VR1 into VR0. Don't copy VR1's equivalence
+ set. We need to compute the intersection of the two
+ equivalence sets. */
if (vr1->type == VR_ANTI_RANGE)
- copy_value_range (vr0, vr1);
+ set_value_range (vr0, vr1->type, vr1->min, vr1->max, vr0->equiv);
/* The resulting set of equivalences is the intersection of
the two sets. */
@@ -3609,7 +3612,7 @@ vrp_visit_phi_node (tree phi)
/* To prevent infinite iterations in the algorithm, derive ranges
when the new value is slightly bigger or smaller than the
previous one. */
- if (lhs_vr->type == VR_RANGE)
+ if (lhs_vr->type == VR_RANGE && vr_result.type == VR_RANGE)
{
if (!POINTER_TYPE_P (TREE_TYPE (lhs)))
{