public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/96167] New: fails to detect ROL pattern in simple case, but succeeds when operand goes through memcpy
@ 2020-07-11 16:10 nok.raven at gmail dot com
  2020-07-13  8:08 ` [Bug tree-optimization/96167] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: nok.raven at gmail dot com @ 2020-07-11 16:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96167
           Summary: fails to detect ROL pattern in simple case, but
                    succeeds when operand goes through memcpy
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nok.raven at gmail dot com
  Target Milestone: ---

inline void swap(int &x, int &y)
{
  int tmp = x;
  x = y;
  y = tmp;
}

void foo(int (&x)[2])
{
  swap(x[0], x[1]);
}

void bar(int (&x)[2])
{
  int y[2];
  __builtin_memcpy(&y, &x, sizeof x);
  swap(y[0], y[1]);
  __builtin_memcpy(&x, &y, sizeof x);
}


foo:
  movl (%rdi), %eax
  movl 4(%rdi), %edx
  movl %eax, 4(%rdi)
  movl %edx, (%rdi)
  ret

bar:
  rolq $32, (%rdi)
  ret

https://godbolt.org/z/Tcz7YG

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

end of thread, other threads:[~2023-08-04 22:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-11 16:10 [Bug tree-optimization/96167] New: fails to detect ROL pattern in simple case, but succeeds when operand goes through memcpy nok.raven at gmail dot com
2020-07-13  8:08 ` [Bug tree-optimization/96167] " rguenth at gcc dot gnu.org
2020-07-15 13:40 ` ebotcazou at gcc dot gnu.org
2020-07-15 13:57 ` jakub at gcc dot gnu.org
2020-07-15 14:04 ` jakub at gcc dot gnu.org
2023-08-04 22:26 ` pinskia at gcc dot gnu.org
2023-08-04 22:31 ` 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).