public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113859] New: popcount HI can be vectorized for non-SVE
@ 2024-02-10  2:15 pinskia at gcc dot gnu.org
  2024-02-10  3:41 ` [Bug target/113859] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-10  2:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113859
           Summary: popcount HI can be vectorized for non-SVE
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---
            Target: aarch64

Take:
```
void f(unsigned short *  __restrict b, unsigned short * __restrict d)
{
  for(int i = 0; i < 1024; i++)
    d[i]  = __builtin_popcount(b[i]);
}

```

This can be vectorized to:
```
        ldr     q0, [x9]
        cnt     v0.16b, v0.16b
        uaddlp  v0.8h, v0.16b
        stp     q0, [x9]
```

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

* [Bug target/113859] popcount HI can be vectorized for non-SVE
  2024-02-10  2:15 [Bug target/113859] New: popcount HI can be vectorized for non-SVE pinskia at gcc dot gnu.org
@ 2024-02-10  3:41 ` pinskia at gcc dot gnu.org
  2024-03-05  0:58 ` pinskia at gcc dot gnu.org
  2024-05-09 18:05 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-10  3:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
SI (and DI) can be optimized too.

LLVM is produces for int:
        ldr     d0, [x0]
        cnt     v0.8b, v0.8b
        uaddlp  v0.4h, v0.8b
        uaddlp  v0.2s, v0.4h
        str     d0, [x1]
        ret

And for long:
```
        ldr     q0, [x0]
        cnt     v0.16b, v0.16b
        uaddlp  v0.8h, v0.16b
        uaddlp  v0.4s, v0.8h
        uaddlp  v0.2d, v0.4s
        str     q0, [x1]
        ret
```

That is for SLP version:
```
void f(unsigned long *  __restrict b, unsigned long * __restrict d)
{
    d[0]  = __builtin_popcountll(b[0]);
    d[1]  = __builtin_popcountll(b[1]);
}
```
s/long/int/ in the first case.

Note using SVE is better than the above if it is available and that is part of
PR 113860 though.

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

* [Bug target/113859] popcount HI can be vectorized for non-SVE
  2024-02-10  2:15 [Bug target/113859] New: popcount HI can be vectorized for non-SVE pinskia at gcc dot gnu.org
  2024-02-10  3:41 ` [Bug target/113859] " pinskia at gcc dot gnu.org
@ 2024-03-05  0:58 ` pinskia at gcc dot gnu.org
  2024-05-09 18:05 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-03-05  0:58 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |pinskia at gcc dot gnu.org
   Last reconfirmed|                            |2024-03-05

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Mine.

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

* [Bug target/113859] popcount HI can be vectorized for non-SVE
  2024-02-10  2:15 [Bug target/113859] New: popcount HI can be vectorized for non-SVE pinskia at gcc dot gnu.org
  2024-02-10  3:41 ` [Bug target/113859] " pinskia at gcc dot gnu.org
  2024-03-05  0:58 ` pinskia at gcc dot gnu.org
@ 2024-05-09 18:05 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-09 18:05 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2024-May/650
                   |                            |311.html

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Patch was posted:
https://gcc.gnu.org/pipermail/gcc-patches/2024-May/650311.html

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

end of thread, other threads:[~2024-05-09 18:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-10  2:15 [Bug target/113859] New: popcount HI can be vectorized for non-SVE pinskia at gcc dot gnu.org
2024-02-10  3:41 ` [Bug target/113859] " pinskia at gcc dot gnu.org
2024-03-05  0:58 ` pinskia at gcc dot gnu.org
2024-05-09 18:05 ` 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).