On Wed, Oct 7, 2015 at 7:43 AM, Jan Hubicka <hubi...@ucw.cz> wrote:
> Hi,
> this patch fixes use of operand_equal_p in fold_comparison where
> we compare two addresses for equivalence and in 
> fold_addr_of_array_ref_difference.
>
> Bootstrapped/regtested x86_64-linux, OK?
>
> Honza
>
>         * fold-const.c (fold_comparison, fold_addr_of_array_ref_difference):
>         Pass OEP_ADDRESS_OF flag to operand_equal_p.
> Index: fold-const.c
> ===================================================================
> --- fold-const.c        (revision 228131)
> +++ fold-const.c        (working copy)
> @@ -8386,7 +8443,7 @@ fold_comparison (location_t loc, enum tr
>
>        /* If we have equivalent bases we might be able to simplify.  */
>        if (indirect_base0 == indirect_base1
> -         && operand_equal_p (base0, base1, 0))
> +         && operand_equal_p (base0, base1, OEP_ADDRESS_OF))

No, we only compare the address of base0 if indirect_base0/1 are true otherwise
we compare plain pointers.

>         {
>           /* We can fold this expression to a constant if the non-constant
>              offset parts are equal.  */
> @@ -8806,7 +8863,7 @@ fold_addr_of_array_ref_difference (locat
>           && (base_offset = fold_binary_loc (loc, MINUS_EXPR, type,
>                                              TREE_OPERAND (base0, 0),
>                                              TREE_OPERAND (base1, 0))))
> -      || operand_equal_p (base0, base1, 0))
> +      || operand_equal_p (base0, base1, OEP_ADDRESS_OF))

This one looks ok.

Ok with proper adjustment for the first case.

Thanks,
Richard.

>      {
>        tree op0 = fold_convert_loc (loc, type, TREE_OPERAND (aref0, 1));
>        tree op1 = fold_convert_loc (loc, type, TREE_OPERAND (aref1, 1));

Reply via email to