public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/52082] New: Memory loads not rematerialized
Date: Wed, 01 Feb 2012 10:30:00 -0000	[thread overview]
Message-ID: <bug-52082-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52082

             Bug #: 52082
           Summary: Memory loads not rematerialized
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, ra
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jakub@gcc.gnu.org
                CC: vmakarov@gcc.gnu.org
            Target: x86_64-linux


On the following testcase at -O2 (distilled from genautomata.c):

struct S { unsigned long *s1; struct S *s2; };
int v1 __attribute__((visibility ("hidden")));
struct T
{
  int a, b, c;
} *v2 __attribute__((visibility ("hidden")));
struct S **v3 __attribute__((visibility ("hidden")));
struct S **v4 __attribute__((visibility ("hidden")));

int __attribute__((noinline, noclone))
foo (unsigned long *x, unsigned long *y, int z)
{
  int j, k, l;
  unsigned int i;
  struct S *m;

  for (j = 0; j < v1; j++)
    if (y[j])
      for (i = 0; i < 8 * sizeof (unsigned long); i++)
  if ((y[j] >> i) & 1)
    {
      k = j * 8 * sizeof (unsigned long) + i;
      if (k >= v2->c)
        break;
      for (m = (z ? v4 [k] : v3 [k]); m != ((void *)0); m = m->s2)
        {
          for (l = 0; l < v1; l++)
            if ((x [l] & m->s1 [l]) != m->s1 [l] && m->s1 [l])
              break;
          if (l >= v1)
            return 0;
        }
    }
  return 1;
}

tree LIM moves the loads from v2/v3/v4 before the loop, but unfortunately the
register pressure is high and the pseudos holding the v3/v4 pointers don't get
a a hard register and are immediately spilled to the stack.  I wonder whether
we couldn't instead just rematerialize them and put the original MEM loads into
the loop (assuming they don't alias with anything on the way, but that must be
the case here when LIM moved them there first, after all this loop doesn't have
any MEM stores at all).


             reply	other threads:[~2012-02-01 10:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-01 10:30 jakub at gcc dot gnu.org [this message]
2012-02-03  2:30 ` [Bug rtl-optimization/52082] " pinskia at gcc dot gnu.org
2021-09-05  4:52 ` 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-52082-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).