public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100973] New: gcc does not optimise based on knowing that `_mm256_movemask_ps` returns less than 255
@ 2021-06-08 17:33 denis.yaroshevskij at gmail dot com
  2021-06-08 20:27 ` [Bug target/100973] " pinskia at gcc dot gnu.org
  2021-06-09  6:43 ` rguenth at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: denis.yaroshevskij at gmail dot com @ 2021-06-08 17:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100973
           Summary: gcc does not optimise based on knowing that
                    `_mm256_movemask_ps` returns less than 255
           Product: gcc
           Version: og10 (devel/omp/gcc-10)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: denis.yaroshevskij at gmail dot com
  Target Milestone: ---

Options: -O3 -std=c++20 -DNDEBUG -mavx

Code:

```
#include <immintrin.h>

int masking_should_evaporate(__m256 values) {
  int top_bits = _mm256_movemask_ps(values);
  top_bits &= 255;
  return top_bits;
}
```

Godbolt: https://gcc.godbolt.org/z/a81qPWcon


For this code top_bits &= 255 does not actually do anything. Clang can optimise
based on that:

```
       vmovmskps       eax, ymm0
       vzeroupper
       ret
```

It comes from real code.

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

* [Bug target/100973] gcc does not optimise based on knowing that `_mm256_movemask_ps` returns less than 255
  2021-06-08 17:33 [Bug c++/100973] New: gcc does not optimise based on knowing that `_mm256_movemask_ps` returns less than 255 denis.yaroshevskij at gmail dot com
@ 2021-06-08 20:27 ` pinskia at gcc dot gnu.org
  2021-06-09  6:43 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-08 20:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |x86_64-linux-gnu
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2021-06-08
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is a target/tree-optimization.  Basically Tree level optimization has no
idea what the builtin does and there is no target hook to querry the back-end
for ranges:
  _3 = __builtin_ia32_movmskps256D.2066 (values_2(D));

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

* [Bug target/100973] gcc does not optimise based on knowing that `_mm256_movemask_ps` returns less than 255
  2021-06-08 17:33 [Bug c++/100973] New: gcc does not optimise based on knowing that `_mm256_movemask_ps` returns less than 255 denis.yaroshevskij at gmail dot com
  2021-06-08 20:27 ` [Bug target/100973] " pinskia at gcc dot gnu.org
@ 2021-06-09  6:43 ` rguenth at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-09  6:43 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com
             Blocks|                            |85316

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Maybe the builtin should return an unsigned char ...

Since we have a target hook for folding we could also add a target hook
for value-range processing of course.  Not sure if it's worth the complication
though and if targets are willing to implement it.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases

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

end of thread, other threads:[~2021-06-09  6:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 17:33 [Bug c++/100973] New: gcc does not optimise based on knowing that `_mm256_movemask_ps` returns less than 255 denis.yaroshevskij at gmail dot com
2021-06-08 20:27 ` [Bug target/100973] " pinskia at gcc dot gnu.org
2021-06-09  6:43 ` rguenth 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).