public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Eric Botcazou <botcazou@adacore.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix recent thinko in operand_equal_p
Date: Fri, 4 Nov 2022 10:40:35 +0100	[thread overview]
Message-ID: <2F00FAAA-AA2A-428D-AC5D-52CCF0FEE86B@gmail.com> (raw)
In-Reply-To: <7447720.EvYhyI6sBW@fomalhaut>



> Am 04.11.2022 um 10:29 schrieb Eric Botcazou via Gcc-patches <gcc-patches@gcc.gnu.org>:
> 
> Hi,
> 
> there is a thinko in the recent improvement by Jan:
> 
> 2020-11-19  Jan Hubicka  <jh@suse.cz>
> 
>    * fold-const.c (operand_compare::operand_equal_p): Fix thinko in
>    COMPONENT_REF handling and guard types_same_for_odr by
>    virtual_method_call_p.
>    (operand_compare::hash_operand): Likewise.
> 
> where the code just looks at operand 2 of COMPONENT_REF, if it is present, to 
> compare addresses.  That's wrong because operand 2 contains the number of 
> DECL_OFFSET_ALIGN-bit-sized words so, when DECL_OFFSET_ALIGN > 8, not all the 
> bytes are included and some of them are in DECL_FIELD_BIT_OFFSET instead, see 
> get_inner_reference for the model computation.
> 
> In other words, you would need to compare operand 2 and DECL_OFFSET_ALIGN and 
> DECL_FIELD_BIT_OFFSET in this situation, but I'm not sure this is worth the 
> hassle in practice so the attached fix just removes this alternate handling.

> Tested on x86-64/Linux, OK for mainline, 12 and 11 branches?

Ok.

Thanks,
Richard 

> 
> 2022-11-04  Eric Botcazou  <ebotcazou@adacore.com>
> 
>    * fold-const.cc (operand_compare::operand_equal_p) <COMPONENT_REF>:
>    Do not take into account operand 2.
>    (operand_compare::hash_operand) <COMPONENT_REF>: Likewise.
> 
> 
> 2022-11-04  Eric Botcazou  <ebotcazou@adacore.com>
> 
>    * gnat.dg/opt99.adb: New test.
>    * gnat.dg/opt99_pkg1.ads, gnat.dg/opt99_pkg1.adb: New helper.
>    * gnat.dg/opt99_pkg2.ads: Likewise.
> 
> -- 
> Eric Botcazou
> <p.diff>
> <opt99.adb>
> <opt99_pkg1.adb>
> <opt99_pkg2.ads>
> <opt99_pkg1.ads>

      reply	other threads:[~2022-11-04  9:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-04  9:27 Eric Botcazou
2022-11-04  9:40 ` Richard Biener [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2F00FAAA-AA2A-428D-AC5D-52CCF0FEE86B@gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=botcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).