https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85531
Bug ID: 85531 Summary: Implement some loop fusion in the Fortran front end Product: gcc Version: unknown Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: tkoenig at gcc dot gnu.org Target Milestone: --- See the discussion starting at https://gcc.gnu.org/ml/gcc/2018-04/msg00128.html . Basically, for code like ZQICE(1:NPROMA,1:NFLEVG) = PGFL(1:NPROMA,1:NFLEVG,YI%MP) ZQLI(1:NPROMA,1:NFLEVG) = PGFL(1:NPROMA,1:NFLEVG,YL%MP) ZQRAIN(1:NPROMA,1:NFLEVG) = PGFL(1:NPROMA,1:NFLEVG,YR%MP) ZQSNOW(1:NPROMA,1:NFLEVG) = PGFL(1:NPROMA,1:NFLEVG,YS%MP) the front end could notice that the right-hand sides always agree and translate this to DO J=1,NFLEVG DO I=1,NPROMA ZQICE(I,J) = PGFL(I,J,YI%MP) ZQLI(I,J) = PGFL(I,J,YI%MP) ZQRAIN(I,J) = PGFL(I,J,YI%MP) ZQSNOW(I,J) = PGFL(I,J,YI%MP) END DO END DO This would require some data flow analysis (are we sure that PGFL is not changed in the meantime?) and some basic block analysis.