public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Two more cases where we compare addresses
@ 2015-10-07  5:43 Jan Hubicka
  2015-10-07  8:49 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Hubicka @ 2015-10-07  5:43 UTC (permalink / raw)
  To: gcc-patches

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))
 	{
 	  /* 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))
     {
       tree op0 = fold_convert_loc (loc, type, TREE_OPERAND (aref0, 1));
       tree op1 = fold_convert_loc (loc, type, TREE_OPERAND (aref1, 1));

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Two more cases where we compare addresses
  2015-10-07  5:43 Two more cases where we compare addresses Jan Hubicka
@ 2015-10-07  8:49 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2015-10-07  8:49 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: GCC Patches

On Wed, Oct 7, 2015 at 7:43 AM, Jan Hubicka <hubicka@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));

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-07  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-07  5:43 Two more cases where we compare addresses Jan Hubicka
2015-10-07  8:49 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).