public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/97707] New: avx12 math function invoked even if -mprefer-vector-width=256 specified
@ 2020-11-03 18:05 vincenzo.innocente at cern dot ch
  2020-11-04  8:24 ` [Bug tree-optimization/97707] avx512 " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2020-11-03 18:05 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97707
           Summary: avx12 math function invoked even if
                    -mprefer-vector-width=256 specified
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincenzo.innocente at cern dot ch
  Target Milestone: ---

this code will invoke _ZGVeN8v_sin instead of _ZGVdN4v_sin making use of zmm
registers
#include<cmath>

int main() {

  double res=0;

  for (int x=0; x<1024;x++) {
    double y = x; 
    res += std::sin(y);
  }


 return res > 0.5;

}

NOTE if I specify
for (long long x=0; x<1024;x++) {

it will correcty invoke _ZGVdN4v_sin (no zmm)


compiler options
-Ofast -march=skylake-avx512 -mprefer-vector-width=256

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

* [Bug tree-optimization/97707] avx512 math function invoked even if -mprefer-vector-width=256 specified
  2020-11-03 18:05 [Bug tree-optimization/97707] New: avx12 math function invoked even if -mprefer-vector-width=256 specified vincenzo.innocente at cern dot ch
@ 2020-11-04  8:24 ` rguenth at gcc dot gnu.org
  2020-11-04  8:47 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-11-04  8:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
                 CC|                            |jakub at gcc dot gnu.org
             Blocks|                            |53947
             Target|                            |x86_64-*-* i?86-*-*
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-11-04

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
-mprefer-vector-width=256 means it _prefers_ AVX256 but then in case
vectorization fails (for whatever bogus reason) with AVX256 it will still try
AVX512:

static unsigned int
ix86_autovectorize_vector_modes (vector_modes *modes, bool all)
{
  if (TARGET_AVX512F && !TARGET_PREFER_AVX256)
    {
      modes->safe_push (V64QImode);
      modes->safe_push (V32QImode);
      modes->safe_push (V16QImode);
    }
  else if (TARGET_AVX512F && all)
    {
      modes->safe_push (V32QImode);
      modes->safe_push (V16QImode);
      modes->safe_push (V64QImode);
    }

the odd thing is that the dumps suggest we use V4DFmode.  We use a VF of 8
because of V8SI and it seems that call vectorization then chooses the
larger vector mode because it is supported - it seems to have its own
idea of costing there (probably reasonable).

Do you think this is a bad idea?


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

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

* [Bug tree-optimization/97707] avx512 math function invoked even if -mprefer-vector-width=256 specified
  2020-11-03 18:05 [Bug tree-optimization/97707] New: avx12 math function invoked even if -mprefer-vector-width=256 specified vincenzo.innocente at cern dot ch
  2020-11-04  8:24 ` [Bug tree-optimization/97707] avx512 " rguenth at gcc dot gnu.org
@ 2020-11-04  8:47 ` jakub at gcc dot gnu.org
  2020-11-04  8:57 ` vincenzo.innocente at cern dot ch
  2020-11-04  8:59 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-04  8:47 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The prefer option is exactly that, try that first and if it fails, use the
others.
So I guess the main question is why it failed for the VF=4 case.
E.g. for -mavx512f it wouldn't surprise me as much, because then AVX512VL is
not in and it could be that AVX2 isn't able to deal with that.

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

* [Bug tree-optimization/97707] avx512 math function invoked even if -mprefer-vector-width=256 specified
  2020-11-03 18:05 [Bug tree-optimization/97707] New: avx12 math function invoked even if -mprefer-vector-width=256 specified vincenzo.innocente at cern dot ch
  2020-11-04  8:24 ` [Bug tree-optimization/97707] avx512 " rguenth at gcc dot gnu.org
  2020-11-04  8:47 ` jakub at gcc dot gnu.org
@ 2020-11-04  8:57 ` vincenzo.innocente at cern dot ch
  2020-11-04  8:59 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2020-11-04  8:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from vincenzo Innocente <vincenzo.innocente at cern dot ch> ---
the main point in using -mprefer-vector-width=256 is to avoid clock throttling
in "mixed" workloads.
In small benchmarks like this one avx512 is faster (even on an old Silver) even
if trigger a slower clock. (and the test should be performed with the machine
fully loaded). Still if I ask  -mprefer-vector-width=256 I would like to see no
512-wide instructions to be used.

A disturbing feature is also the difference between using int or long long as
loop index.

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

* [Bug tree-optimization/97707] avx512 math function invoked even if -mprefer-vector-width=256 specified
  2020-11-03 18:05 [Bug tree-optimization/97707] New: avx12 math function invoked even if -mprefer-vector-width=256 specified vincenzo.innocente at cern dot ch
                   ` (2 preceding siblings ...)
  2020-11-04  8:57 ` vincenzo.innocente at cern dot ch
@ 2020-11-04  8:59 ` jakub at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-04  8:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If you want no AVX512* instructions, the option to say that is -mno-avx512f

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

end of thread, other threads:[~2020-11-04  8:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 18:05 [Bug tree-optimization/97707] New: avx12 math function invoked even if -mprefer-vector-width=256 specified vincenzo.innocente at cern dot ch
2020-11-04  8:24 ` [Bug tree-optimization/97707] avx512 " rguenth at gcc dot gnu.org
2020-11-04  8:47 ` jakub at gcc dot gnu.org
2020-11-04  8:57 ` vincenzo.innocente at cern dot ch
2020-11-04  8:59 ` jakub 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).