<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/66452>66452</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang] Compilation of DATA statement for large COMPLEX arrays needs a lot of time
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue,
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yus3710-fj
</td>
</tr>
</table>
<pre>
This is an issue from Fujitsu testsuite.
#63610 about memory shortage has been fixed, but the compilation takes a long time.
(The compilation command is executed with `ulimit -t 300` in Fujitsu testsuite.)
The following are the test program, the result of `time` command of flang-new and gfortran compilation.
```fortran
! test.f90
complex(kind=8),dimension(1000) :: a8
complex(kind=8),dimension(1000,1000) :: b8
complex(kind=16),dimension(1000) :: a16
complex(kind=16),dimension(1000,1000) :: b16
data a8/1000*(0.0,0.0)/,a16/1000*(0.0,0.0)/
data b8/1000000*(0.0,0.0)/,b16/1000000*(0.0,0.0)/
end
```
```console
$ time flang-new -v test.f90
flang-new version 18.0.0 (https://github.com/llvm/llvm-project.git 444abb396c340e52a8a4db5778b7d6b3b6195070)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /usr/lib/gcc/aarch64-redhat-linux/8
Selected GCC installation: /usr/lib/gcc/aarch64-redhat-linux/8
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +neon -target-feature +v8a -o /tmp/test-6590a6.o -x f95-cpp-input test.f90
"/usr/bin/ld" -pie -EL --hash-style=gnu --eh-frame-hdr -m aarch64linux -dynamic-linker /lib/ld-linux-aarch64.so.1 -o a.out /usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/Scrt1.o /usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/crti.o /usr/lib/gcc/aarch64-redhat-linux/8/crtbeginS.o -L/path/to/install/lib/clang/18/lib/aarch64-unknown-linux-gnu -L/usr/lib/gcc/aarch64-redhat-linux/8 -L/usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib /tmp/test-6590a6.o -L/path/to/install/lib -lFortran_main -lFortranRuntime -lFortranDecimal -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/aarch64-redhat-linux/8/crtendS.o /usr/lib/gcc/aarch64-redhat-linux/8/../../../../lib64/crtn.o
real 18m5.933s
user 18m5.553s
sys 0m0.239s
```
```console
$ time gfortran -v test.f90
Driving: gfortran -v test.f90 -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)
:
real 0m0.117s
user 0m0.091s
sys 0m0.004s
```
It seems that semantics takes a long time.
```console
$ time flang-new -fc1 -fdebug-dump-parse-tree-no-sema test.f90
Program -> ProgramUnit -> MainProgram
| SpecificationPart
:
| ExecutionPart -> Block
| EndProgramStmt ->
real 0m0.781s
user 0m0.495s
sys 0m0.061s
$ time flang-new -fc1 -fdebug-dump-parse-tree test.f90
Program -> ProgramUnit -> MainProgram
| SpecificationPart
:
| ExecutionPart -> Block
| EndProgramStmt ->
real 18m8.254s
user 18m7.959s
sys 0m0.160s
$ time flang-new -fc1 -emit-fir test.f90
real 17m37.932s
user 17m37.596s
sys 0m0.190s
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWF9v4zgO_zTqCyFDlhMnfuhDJ2n2DuhiB9Mu7t4KWaYdTWXJJ8ltup_-IP9J00zb2w7m5QaFJ6Yo_vmRIikL71VjEC_J8gtZbi9EH_bWXT73PluljNbfL0pbPV_e7ZUH5UEYUN73CLWzLez67yr4HgL64HsVMCFsS9jV9ORZnuUpA1HaPkCLrXXP4PfWBdEg7IWHEtFArQ5YEb6Bsg8Q9gjStp3SIihrIIgH9CBAW9NAUO1RBV_fnbFK27bCVNFMPKDsA1bwpMIeSM56rVoVgAbIGCM5A2Xesp4Xpw5EBbXV2j4p04BwOFgX2aFztnGijVZHmkPf6wC2jrqilVHFbI-todbCNNTgE0RCU1sXnDCn1r9GLmfj38Q4u5wOypO6YCMl7td4IHz9oExFsu06esA3lWrReGUN4euUMUZ4AfEfya5IdgVi_dntm6OUSUT5nog0_9CE2YI0__T-ow2zCbOM8VmJIKJnfDfyxQxhSdw3PAvCd4RvouKPOF5ElbOoD6SVR2kfCxyfaKqz8J69Smu81ThHezHk-0nu0Mdj_GFkell7RBfRgnSdsIQB4et9CJ2PWEVTd40K-75MpG0J32n9OP9HO2e_owxJowIsFgtRllmRy2zBcMnFWiyqcrlarctVlZdZmafFkq3Y8ZzcCddgGCIqnNznC9qbB2OfDNXK9AfamH4-Sg5FBa2tUEf2znp1GJf-aXwQWmO1VS4uEb7rRNgTvguW8J0alwnflWo6CDvbmwqkMJWqRED4bbOBiW04S5OU3rvopCqj-1ISvpuNdFjtRRhtJHw35fItapSxaPwieZujgW2vg4obsytISPaFLFibL860fsQEhPMPceG7YyoQzoHWMgUanOo0vh8aoNiqQG35PW6w2jp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