public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/66862] New: OpenMP SIMD does not work (use SIMD instructions) on conditional code
@ 2015-07-13 16:39 bill.jordan at intel dot com
  2015-07-13 16:42 ` [Bug c/66862] " bill.jordan at intel dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: bill.jordan at intel dot com @ 2015-07-13 16:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 66862
           Summary: OpenMP SIMD does not work (use SIMD instructions) on
                    conditional code
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bill.jordan at intel dot com
  Target Milestone: ---

Created attachment 35971
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35971&action=edit
SIMD sample code

In the following loop,the omp simd pragma has no affect:

 #pragma omp simd private(value) linear(ij, kj) safelen(64)
 for (j = 0; j < switches; ++j) {
     value = cost[ik] + cost[kj];
     if (value < cost[ij]) {
         cost[ij] = value;
     }
     ++ij; ++kj;
 }

Without the "if" clause, the compiler will generate SIMD code.

Compilation line is:
 gcc -Wall -Wextra -O3 -save-temps -fopenmp-simd -c floyds_simd.c

Attached source includes 4 routines:
 floyds_wo_omp_simd: Base function.
 floyds_w_omp_simd: Base function with #pragma omp simd directive
 not_floyds_wo_omp_simd: Base function without if clause
 not_floyds_w_omp_simd: Base function without if clause with #pragma omp simd


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

* [Bug c/66862] OpenMP SIMD does not work (use SIMD instructions) on conditional code
  2015-07-13 16:39 [Bug c/66862] New: OpenMP SIMD does not work (use SIMD instructions) on conditional code bill.jordan at intel dot com
@ 2015-07-13 16:42 ` bill.jordan at intel dot com
  2015-07-14  4:19 ` [Bug tree-optimization/66862] " pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bill.jordan at intel dot com @ 2015-07-13 16:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from William Jordan <bill.jordan at intel dot com> ---
Created attachment 35972
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35972&action=edit
Disassembled code

Assembly shows that code generated with #pragma omp simd is the same as without
when the "for" loop contains an "if" statement. Without the "if" statement, the
#pragma omp simd uses SIMD operations seen in not_floyds_w_omp_simd function.


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

* [Bug tree-optimization/66862] OpenMP SIMD does not work (use SIMD instructions) on conditional code
  2015-07-13 16:39 [Bug c/66862] New: OpenMP SIMD does not work (use SIMD instructions) on conditional code bill.jordan at intel dot com
  2015-07-13 16:42 ` [Bug c/66862] " bill.jordan at intel dot com
@ 2015-07-14  4:19 ` pinskia at gcc dot gnu.org
  2015-07-14  8:18 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-07-14  4:19 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |tree-optimization

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
There is an optimization which should have converted the loop to use
uncondtional stores.  I wonder why it is not happening in this case.


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

* [Bug tree-optimization/66862] OpenMP SIMD does not work (use SIMD instructions) on conditional code
  2015-07-13 16:39 [Bug c/66862] New: OpenMP SIMD does not work (use SIMD instructions) on conditional code bill.jordan at intel dot com
  2015-07-13 16:42 ` [Bug c/66862] " bill.jordan at intel dot com
  2015-07-14  4:19 ` [Bug tree-optimization/66862] " pinskia at gcc dot gnu.org
@ 2015-07-14  8:18 ` rguenth at gcc dot gnu.org
  2015-07-14  8:50 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-07-14  8:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
store data-races


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

* [Bug tree-optimization/66862] OpenMP SIMD does not work (use SIMD instructions) on conditional code
  2015-07-13 16:39 [Bug c/66862] New: OpenMP SIMD does not work (use SIMD instructions) on conditional code bill.jordan at intel dot com
                   ` (2 preceding siblings ...)
  2015-07-14  8:18 ` rguenth at gcc dot gnu.org
@ 2015-07-14  8:50 ` jakub at gcc dot gnu.org
  2024-03-18  0:53 ` liuhongt at gcc dot gnu.org
  2024-04-08  8:27 ` liuhongt at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2015-07-14  8:50 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |kyukhin at gcc dot gnu.org,
                   |                            |uros at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If you sed -i 's/short/int/' on the testcase, then e.g. with -mavx2 it is
vectorized with vmaskmovd.  But AVX2 does not have a masked store for packed
16-bit integers, and as Richard mentioned, using vpminuw/vmovdqu that icc emits
is IMHO invalid, as it introduces a store data race and I see no wording in the
OpenMP standard that would allow introducing store data races, even in omp simd
regions.

Now, it seems AVX512BW (and AVX512VL in some cases) has the needed
instructions,
in particular VMOVDQU{8,16}, but it is not reflected in maskload<mode> and
maskstore<mode> expanders.  CCing Kyrill and Uros on this.


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

* [Bug tree-optimization/66862] OpenMP SIMD does not work (use SIMD instructions) on conditional code
  2015-07-13 16:39 [Bug c/66862] New: OpenMP SIMD does not work (use SIMD instructions) on conditional code bill.jordan at intel dot com
                   ` (3 preceding siblings ...)
  2015-07-14  8:50 ` jakub at gcc dot gnu.org
@ 2024-03-18  0:53 ` liuhongt at gcc dot gnu.org
  2024-04-08  8:27 ` liuhongt at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-03-18  0:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
> Now, it seems AVX512BW (and AVX512VL in some cases) has the needed
> instructions,
> in particular VMOVDQU{8,16}, but it is not reflected in maskload<mode> and
> maskstore<mode> expanders.  CCing Kyrill and Uros on this.

w/ -mavx512bw and -mavx512vl, the loop is vectorized since GCC 8.1.

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

* [Bug tree-optimization/66862] OpenMP SIMD does not work (use SIMD instructions) on conditional code
  2015-07-13 16:39 [Bug c/66862] New: OpenMP SIMD does not work (use SIMD instructions) on conditional code bill.jordan at intel dot com
                   ` (4 preceding siblings ...)
  2024-03-18  0:53 ` liuhongt at gcc dot gnu.org
@ 2024-04-08  8:27 ` liuhongt at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: liuhongt at gcc dot gnu.org @ 2024-04-08  8:27 UTC (permalink / raw)
  To: gcc-bugs

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

Hongtao Liu <liuhongt at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Hongtao Liu <liuhongt at gcc dot gnu.org> ---
Fixed since GCC8 w/ avx512bw avx512vl.
w/o avx512bw, x86 doesn't support packed int16 mask{load,store}, and can't
vectorize the loop.

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

end of thread, other threads:[~2024-04-08  8:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-13 16:39 [Bug c/66862] New: OpenMP SIMD does not work (use SIMD instructions) on conditional code bill.jordan at intel dot com
2015-07-13 16:42 ` [Bug c/66862] " bill.jordan at intel dot com
2015-07-14  4:19 ` [Bug tree-optimization/66862] " pinskia at gcc dot gnu.org
2015-07-14  8:18 ` rguenth at gcc dot gnu.org
2015-07-14  8:50 ` jakub at gcc dot gnu.org
2024-03-18  0:53 ` liuhongt at gcc dot gnu.org
2024-04-08  8:27 ` liuhongt 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).