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

--- Comment #2 from xiao....@compiler-dev.com <xiao....@compiler-dev.com> ---
(In reply to Jakub Jelinek from comment #1)
> Under discussions in OpenMP language committee, but the latest proposal is
> that this is invalid, you need to increment the linear variable by
> linear-step in the body of the construct.  If that is voted into 5.2, we
> won't be changing GCC for this which always assumed that is the case.  Not
> incrementing it in the body means that the testcase will behave
> significantly differently with -fno-openmp, and also result in worse
> generated code for many cases that do increment the linear variables.

Thanks for your reply. Indeed, all the testcases I have came across about
linear clause within loop construct have the increment for linear variable in
loop body, but mostly testcases about linear clause within simd construct
don't.
Could you help to confirm whether linear clause within simd construct is
handled correctly in the following testcase?

program p
  integer, parameter :: M = 10000
  integer :: b
  integer :: c(M), i
  b = 10
  !$omp simd linear(b:5)
  do i = 1, M
    c(i) = b
  end do
  print *, c(1), c(2), c(3), c(4), c(M)
  print *, "final b:", b
end program

When compile with option -O0, the output is,

          10          10          10          10          10
 final b:          10

when compile with option -O1, -O2, -O3 or -Os, the output is,

          10          15          20          25       50005
 final b:       50005

Reply via email to