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

            Bug ID: 106353
           Summary: [suboptimal] Why is a 3D array initialized, use case 2
                    two-layer loop?
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhongyunde at huawei dot com
  Target Milestone: ---

We can see that, the icc use a two-layer loop to initialize a 3D array, and the
inner loop initialize the low 2D of the array (48552 = 1156 * 42); 
while the gfortran use 2 two-layer loop, it is obviously not efficient,
although I don't understand this logic.

test case, see detail in https://godbolt.org/z/nqKansKan
```
program small
  implicit none
  integer, parameter :: ADM_gall = 1156
  integer, parameter :: ADM_kall = 42
  integer, parameter :: ADM_lall = 2
  integer, parameter :: ADM_gall_pl = 6 
  integer, parameter :: ADM_lall_pl = 2

  real(8) :: rhogvx   (ADM_gall,   ADM_kall,ADM_lall   ) ! rho*Vx ( gam2 X
G^{1/2} )
  real(8) :: rhogvx_pl(ADM_gall_pl,ADM_kall,ADM_lall_pl)

  rhogvx=2
  !rhogvx_pl=2

  call src_flux_convergence(rhogvx, rhogvx_pl)
endprogram small
```

Reply via email to