Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Performance issue] Dead code don't remove in flang front end #1230

Open
vfdff opened this issue Mar 8, 2022 · 1 comment
Open

[Performance issue] Dead code don't remove in flang front end #1230

vfdff opened this issue Mar 8, 2022 · 1 comment

Comments

@vfdff
Copy link

vfdff commented Mar 8, 2022

Base the following code, all the pointer malloced are not used outside the function, so all of them are dead code. We'll see that
gfortran will delete the dead code the the very early tree-dump, and only leave 3 movl to retrun the arguments(reference to https://godbolt.org/z/3dMc1n1x1). while flang doen't do similar optimization.

  • gfortran -march=armv8.2-a -g -O3 -ffast-math -fivopts -ftree-vectorize -lm simple.f90 -o simple.gcc.s -S -v -save-temps -fdump-tree-all
subroutine test(ij, l, k, N)
    integer :: ij, k, l, N
	integer, parameter :: ADM_gall = 1156
    integer, parameter :: ADM_kall = 42
    integer, parameter :: ADM_lall = 2
    real(8), dimension(N,N,N) :: rhog, rhogvx, rhogvy, rhogvz, rhogw, rhoge, rhog_split
    real(8), dimension(N,N,N) :: rhogvx_split, rhogvy_split, rhogvz_split, rhogw_split, rhoge_split 
    !---------------------------------------------------------------------------
 
    !--- update prognostic variables
    do l = 1, ADM_lall
       do k  = 1, ADM_kall
       do ij = 1, ADM_gall
             rhog  (ij,k,l) = rhog  (ij,k,l) + rhog_split  (ij,k,l)
             rhogvx(ij,k,l) = rhogvx(ij,k,l) + rhogvx_split(ij,k,l)
             rhogvy(ij,k,l) = rhogvy(ij,k,l) + rhogvy_split(ij,k,l)
             rhogvz(ij,k,l) = rhogvz(ij,k,l) + rhogvz_split(ij,k,l)
             rhogw (ij,k,l) = rhogw (ij,k,l) + rhogw_split (ij,k,l)
             rhoge (ij,k,l) = rhoge (ij,k,l) + rhoge_split (ij,k,l)
       enddo
       enddo
    enddo
 end
@vfdff
Copy link
Author

vfdff commented Apr 19, 2022

while gfortran doesn't delete the initializtion in following smart case . https://godbolt.org/z/oenTK4rMn

subroutine t(v, row, col)
  integer :: row
  integer :: col
  integer(8) :: v (row, col)

  v = 2 // initializtion all elements 
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant