public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "krebbel at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/107372] New: Loop distribution create memcpy between structs with different storage order
Date: Mon, 24 Oct 2022 07:48:12 +0000	[thread overview]
Message-ID: <bug-107372-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 107372
           Summary: Loop distribution create memcpy between structs with
                    different storage order
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: krebbel at gcc dot gnu.org
  Target Milestone: ---

For t.c with "gcc -O3 t.c":

struct L
{
  unsigned int val[256];
} __attribute__((scalar_storage_order ("little-endian")));

struct B
{
  unsigned int val[256];
} __attribute__((scalar_storage_order ("big-endian")));

void
foo (struct L *restrict l, struct B *restrict b)
{
  int i;
  for (i = 0; i < 256; i++)
    l->val[i] = b->val[i];
}


The loop distribution pass currently generates a memcpy although it recognizes
correctly that both sides of the assignment have different storage order:

Analyzing # of iterations of loop 1
  exit condition [255, + , 4294967295] != 0
  bounds on difference of bases: -255 ... -255
  result:
    # of iterations 255, bounded by 255
Creating dr for *b_5(D).val[i_11]
analyze_innermost: t.c:16:23: missed: failed: reverse storage order.

...

void foo (struct L * restrict l, struct B * restrict b)
{
  int i;

  <bb 2> [local count: 10737416]:
  __builtin_memcpy (l_6(D), b_5(D), 1024);
  return;

}

             reply	other threads:[~2022-10-24  7:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24  7:48 krebbel at gcc dot gnu.org [this message]
2022-10-24  7:49 ` [Bug tree-optimization/107372] " krebbel at gcc dot gnu.org
2022-10-24 13:23 ` [Bug tree-optimization/107372] Loop distribution creates " rguenth at gcc dot gnu.org
2024-03-10  0:44 ` pinskia at gcc dot gnu.org
2024-03-10  0:45 ` 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-107372-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).