[PATCH] Fix PR28187, endless looping in VRP

Richard Guenther rguenther@suse.de
Thu Jul 6 13:17:00 GMT 2006


On Thu, 6 Jul 2006, Diego Novillo wrote:

> Richard Guenther wrote on 07/06/06 02:42:
> 
> >     /* 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));
> >
> How about we change operand_equal_p/bitmap_equal_p to support (a)
> pointer comparison, and (b) either operand being NULL_TREE, or add:
> 
> static inline bool
> vrp_operand_equal_p (tree val1, tree val2)
> {
>    return val1
>           && val2
>           && (val1 == val2
>               || operand_equal_p (val1, val2, 0));
> }
> 
> static inline bool
> vrp_bitmap_equal_p (bitmap b1, bitmap b2)
> {
>    return b1
>           && b2
>           && (b1 == b2
>               || bitmap_equal_p (b1, b2));
> }
> 
> The assignment to is_new becomes:
> 
> is_new = !vrp_operand_equal_p (old_vr->type, new_vr->type)
>          || !vrp_operand_equal_p (old_vr->min, new_vr->min)
>          || !vrp_operand_equal_p (old_vr->max, new_vr->max)
>          || !vrp_bitmap_equal_p (old_vr->equiv, new_vr->equiv);

While I think that doing pointer comparison in operand_equal_p to
test for equality is useful in general, the other cases (one argument
being NULL and the bitmap case) is a VRP speciality.  Also this
is only used in update_value_range and introducing vrp_operand_equal_p
and vrp_bitmap_equal_p will make the occasional reader wonder what
is so special about these.

I can add some commentary above or in the chain of tests though.

Thanks,
Richard.

--
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs



More information about the Gcc-patches mailing list