public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/96457] New: PRE gets confused by punned load handling
Date: Tue, 04 Aug 2020 11:44:19 +0000	[thread overview]
Message-ID: <bug-96457-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96457

            Bug ID: 96457
           Summary: PRE gets confused by punned load handling
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

int flag;
union { double f; unsigned long long i; } u;
void foo();
unsigned long long i;
unsigned long long
test ()
{
  double f = 0.;
  if (flag)
    {
      foo ();
      f = u.f;
    }
  else
    i = u.i;
  f = u.f + f;
  return f;
}

here we fail to PRE the load of u.f because PHI translation to the else
path fails since we run into

            /* If we'd have to convert things we would need to validate
               if we can insert the translated expression.  So fail
               here for now - we cannot insert an alias with a different
               type in the VN tables either, as that would assert.  */
            if (result
                && !useless_type_conversion_p (ref->type, TREE_TYPE (result)))
              return NULL;

because we found a value for u.f there, that of u.i (because we value-number
them the same).  If one replaces 'i = u.i;' with 'foo ();' we appropriately
insert a load from u.f in the else path and remove the partial redundancy.

             reply	other threads:[~2020-08-04 11:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-04 11:44 rguenth at gcc dot gnu.org [this message]
2020-08-04 11:44 ` [Bug tree-optimization/96457] " rguenth at gcc dot gnu.org
2020-08-04 12:05 ` rguenth at gcc dot gnu.org
2021-05-18  7:06 ` rguenth at gcc dot gnu.org
2021-07-28 20:28 ` pinskia at gcc dot gnu.org

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=bug-96457-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).