public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106910] New: roundss not vectorized
@ 2022-09-12 16:15 pilarlatiesa at gmail dot com
  2022-09-12 16:35 ` [Bug target/106910] " pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: pilarlatiesa at gmail dot com @ 2022-09-12 16:15 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106910
           Summary: roundss not vectorized
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pilarlatiesa at gmail dot com
  Target Milestone: ---

GCC 7 and newer optimize `std::floor(float)` into `vroundss` with -O2 and
-march=skylake, which is great.

However, I can see in Compiler Explorer that the following example:

```
#include <cmath>

struct TVec { float x, y; };

struct TKey { int i, j; };

class TDom
{
private:
  static int Floor(float const x)
    { return static_cast<int>(std::floor(x)); }

public:
  TKey CalcKey(TVec const &) const;
};

TKey TDom::CalcKey(TVec const &r) const
  { return {Floor(r.x), Floor(r.y)}; }
```

produces:

```

vxorps      %xmm1, %xmm1, %xmm1
vroundss    $9, (%rsi), %xmm1, %xmm0
vroundss    $9, 4(%rsi), %xmm1, %xmm1
vunpcklps   %xmm1, %xmm0, %xmm0
vcvttps2dq  %xmm0, %xmm2
vmovq       %xmm2, %rax
ret
```

Couldn’t the pair of `vroundss` have been merged into a single `vroundps`?

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

end of thread, other threads:[~2022-09-22  7:52 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-12 16:15 [Bug c++/106910] New: roundss not vectorized pilarlatiesa at gmail dot com
2022-09-12 16:35 ` [Bug target/106910] " pinskia at gcc dot gnu.org
2022-09-13  6:31 ` rguenth at gcc dot gnu.org
2022-09-13  7:30 ` crazylht at gmail dot com
2022-09-15  9:35 ` crazylht at gmail dot com
2022-09-15 11:40 ` rguenther at suse dot de
2022-09-16  7:45 ` cvs-commit at gcc dot gnu.org
2022-09-20  6:54 ` cvs-commit at gcc dot gnu.org
2022-09-20  7:00 ` crazylht at gmail dot com
2022-09-21 10:44 ` pilarlatiesa at gmail dot com
2022-09-22  1:09 ` crazylht at gmail dot com
2022-09-22  1:27 ` crazylht at gmail dot com
2022-09-22  7:45 ` pilarlatiesa at gmail dot com
2022-09-22  7:52 ` crazylht 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).