public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/99504] New: Missing memmove detection
@ 2021-03-10  2:52 crazylht at gmail dot com
  2021-03-10  8:30 ` [Bug tree-optimization/99504] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: crazylht at gmail dot com @ 2021-03-10  2:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99504
           Summary: Missing memmove detection
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
                CC: hjl.tools at gmail dot com
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu

cat test.c

typedef struct
{
    unsigned char r,g,b,c;
}pixel;

void
foo_memmov (pixel* p, pixel* q, int n)
{
    for (int i = 0; i != n; i++)
      *p++ = *q++; 
}

void
foo_int (int* p, int* q, int n)
{
    for (int i = 0; i != n; i++)
      *p++ = *q++; 
}

gcc -Ofast -march=skylake

https://godbolt.org/z/hbnTfM

1. Not memmov optimization
2. Why didn't vectorizer optimize foo_memmov like foo_int did.

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

* [Bug tree-optimization/99504] Missing memmove detection
  2021-03-10  2:52 [Bug tree-optimization/99504] New: Missing memmove detection crazylht at gmail dot com
@ 2021-03-10  8:30 ` rguenth at gcc dot gnu.org
  2021-03-17 14:29 ` cvs-commit at gcc dot gnu.org
  2021-03-17 14:31 ` hjl.tools at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-03-10  8:30 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2021-03-10

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that in the pixel case we have an aggregate assignment:

  <bb 3> [local count: 955630225]:
  # p_17 = PHI <p_10(6), p_5(D)(5)>
  # q_18 = PHI <q_9(6), q_6(D)(5)>
  # i_19 = PHI <i_12(6), 0(5)>
  q_9 = q_18 + 4;
  p_10 = p_17 + 4;
  *p_17 = *q_18;
  i_12 = i_19 + 1;
  if (n_8(D) != i_12)
    goto <bb 6>; [89.00%]
  else
    goto <bb 4>; [11.00%]

and that's not handled by vectorization or dependence analysis.

We might want to consider applying the same folding to this as we do for
memcpy folding and turn it into

  _42 = MEM<unsigned int> [q_18, (pixel *)0];
  MEM<unsigned int> [q_17, (pixel *)0] = _42;

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

* [Bug tree-optimization/99504] Missing memmove detection
  2021-03-10  2:52 [Bug tree-optimization/99504] New: Missing memmove detection crazylht at gmail dot com
  2021-03-10  8:30 ` [Bug tree-optimization/99504] " rguenth at gcc dot gnu.org
@ 2021-03-17 14:29 ` cvs-commit at gcc dot gnu.org
  2021-03-17 14:31 ` hjl.tools at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-17 14:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:

https://gcc.gnu.org/g:adf14bdbc10d4114865a08cf20020a2616039057

commit r11-7701-gadf14bdbc10d4114865a08cf20020a2616039057
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Mar 11 06:48:24 2021 -0800

    x86: Update 'P' operand modifier for -fno-plt

    Update 'P' operand modifier for -fno-plt to support inline assembly
    statements.  In 64-bit, we can always load function address with
    @GOTPCREL.  In 32-bit, we load function address with @GOT only for
    non-PIC since PIC register may not be available at call site.

    gcc/

            PR target/99504
            * config/i386/i386.c (ix86_force_load_from_GOT_p): Support
            inline assembly statements.
            (ix86_print_operand): Update 'P' handling for -fno-plt.

    gcc/testsuite/

            PR target/99504
            * gcc.target/i386/pr99530-1.c: New test.
            * gcc.target/i386/pr99530-2.c: Likewise.
            * gcc.target/i386/pr99530-3.c: Likewise.
            * gcc.target/i386/pr99530-4.c: Likewise.
            * gcc.target/i386/pr99530-5.c: Likewise.
            * gcc.target/i386/pr99530-6.c: Likewise.

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

* [Bug tree-optimization/99504] Missing memmove detection
  2021-03-10  2:52 [Bug tree-optimization/99504] New: Missing memmove detection crazylht at gmail dot com
  2021-03-10  8:30 ` [Bug tree-optimization/99504] " rguenth at gcc dot gnu.org
  2021-03-17 14:29 ` cvs-commit at gcc dot gnu.org
@ 2021-03-17 14:31 ` hjl.tools at gmail dot com
  2 siblings, 0 replies; 4+ messages in thread
From: hjl.tools at gmail dot com @ 2021-03-17 14:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to CVS Commits from comment #2)
> The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>:
> 
> https://gcc.gnu.org/g:adf14bdbc10d4114865a08cf20020a2616039057
> 
> commit r11-7701-gadf14bdbc10d4114865a08cf20020a2616039057
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Thu Mar 11 06:48:24 2021 -0800
> 
>     x86: Update 'P' operand modifier for -fno-plt
>     
>     Update 'P' operand modifier for -fno-plt to support inline assembly
>     statements.  In 64-bit, we can always load function address with
>     @GOTPCREL.  In 32-bit, we load function address with @GOT only for
>     non-PIC since PIC register may not be available at call site.
>     
>     gcc/
>     
>             PR target/99504
>             * config/i386/i386.c (ix86_force_load_from_GOT_p): Support
>             inline assembly statements.
>             (ix86_print_operand): Update 'P' handling for -fno-plt.
>     
>     gcc/testsuite/
>     
>             PR target/99504
>             * gcc.target/i386/pr99530-1.c: New test.
>             * gcc.target/i386/pr99530-2.c: Likewise.
>             * gcc.target/i386/pr99530-3.c: Likewise.
>             * gcc.target/i386/pr99530-4.c: Likewise.
>             * gcc.target/i386/pr99530-5.c: Likewise.
>             * gcc.target/i386/pr99530-6.c: Likewise.

Wrong PR number in commit log.

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

end of thread, other threads:[~2021-03-17 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10  2:52 [Bug tree-optimization/99504] New: Missing memmove detection crazylht at gmail dot com
2021-03-10  8:30 ` [Bug tree-optimization/99504] " rguenth at gcc dot gnu.org
2021-03-17 14:29 ` cvs-commit at gcc dot gnu.org
2021-03-17 14:31 ` hjl.tools 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).