public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/111657] New: Memory copy with structure assignment from named address space is not working
@ 2023-10-01 21:41 ubizjak at gmail dot com
  2023-10-01 21:57 ` [Bug middle-end/111657] " ubizjak at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ubizjak at gmail dot com @ 2023-10-01 21:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111657
           Summary: Memory copy with structure assignment from named
                    address space is not working
           Product: gcc
           Version: 12.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ubizjak at gmail dot com
  Target Milestone: ---

Taken from [1]. Compile the following testcase with -O2 -mno-sse:

--cut here--
struct a
{
  long arr[30];
};

__seg_gs struct a m;

void
foo (struct a *dst)
{
  *dst = m;
}
--cut here--

the produced assembly:

foo:
.LFB0:
        xorl    %eax, %eax
        cmpq    $240, %rax
        jnb     .L5
.L2:
        movzbl  %gs:m(%rax), %edx
        movb    %dl, (%rdi,%rax)
        addq    $1, %rax
        cmpq    $240, %rax
        jb      .L2
.L5:
        ret

As rightfully said in [1]:

"...and look at the end result. It's complete and utter sh*t:

<...>

to the point that I can only go "WTF"?

I mean, it's not just that it does the copy one byte at a time. It
literally compares %rax to $240 just after it has cleared it. I look
at that code, and I go "a five-year old with a crayon could have done
better".

[1]
https://lore.kernel.org/lkml/CAHk-=wh+cfn58XxMLnG6dH+Eb9-2dYfABXJF2FtSZ+vfqVvWzA@mail.gmail.com/

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

end of thread, other threads:[~2023-11-17 13:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-01 21:41 [Bug middle-end/111657] New: Memory copy with structure assignment from named address space is not working ubizjak at gmail dot com
2023-10-01 21:57 ` [Bug middle-end/111657] " ubizjak at gmail dot com
2023-10-01 22:26 ` pinskia at gcc dot gnu.org
2023-10-01 22:31 ` [Bug target/111657] Memory copy with structure assignment from named address space should be improved pinskia at gcc dot gnu.org
2023-10-02  9:21 ` ubizjak at gmail dot com
2023-10-02  9:25 ` ubizjak at gmail dot com
2023-10-05 15:43 ` cvs-commit at gcc dot gnu.org
2023-10-05 15:46 ` ubizjak at gmail dot com
2023-11-17 12:07 ` jakub at gcc dot gnu.org
2023-11-17 13:39 ` ubizjak at gmail dot com

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