public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/96457] New: PRE gets confused by punned load handling
@ 2020-08-04 11:44 rguenth at gcc dot gnu.org
  2020-08-04 11:44 ` [Bug tree-optimization/96457] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-04 11:44 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2021-07-28 20:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 11:44 [Bug tree-optimization/96457] New: PRE gets confused by punned load handling rguenth at gcc dot gnu.org
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

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).