https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90656
Bug ID: 90656
Summary: Illegal operand from Fortran program WRF with
mcpu=niagara3
Product: gcc
Version: 9.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mailboxnotfound at yahoo dot com
Target Milestone: ---
Created attachment 46426
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46426&action=edit
tarball, md5sum is 3cba3d5be4b05751298c6dbcb824f06d
Introduction
Compiling 521.wrf_r from SPEC CPU 2017 with gcc 9.1 on SPARC Linux fails
with message
module_cu_nsas.fppized.s: Assembler messages:
module_cu_nsas.fppized.s:8432: Error: Illegal operands
and indeed the operand is illegal - %f25 is only a single precision
register:
$ head -8432 module_cu_nsas.fppized.s | tail -1
std %f25, [%fp+1799]
$
Also fails with WRF
You do not need SPEC CPU 2017 to reproduce this problem. The reproducer
script
for this bug starts from
https://raw.githubusercontent.com/NCAR/WRFV3/master/phys/module_cu_nsas.F
New with 9.1
The error does not occur with gcc 8.3. I built my copy of GCC 9.1 on a
SPARC T8
running Oracle Linux 6.9 with these add-ins to the source directory:
binutils-2.32 gmp-6.1.2 isl-0.19 mpc-1.1.0 mpfr-3.1.6
and this configure command:
/export/GCC/build/gcc-9.1.0/configure --enable-languages=c,c++,fortran
--enable-lto
--enable-bootstrap --with-cpu=ultrasparc
--with-pkgversion=johnh-16-May-2019
--prefix=/export/GCC/gcc-9.1.0 --with-local-prefix=/export/GCC
Optimization
Original:
-Ofast -mcpu=niagara4
In the reproducer, I got it down to:
-O3 -fstack-arrays -ffinite-math-only -mcpu=niagara3
Furthermore, it still fails even if many of the components of O3 are turned
off:
-fno-inline-functions -fno-predictive-commoning -fno-gcse-after-reload
-fno-tree-loop-distribution -fno-tree-loop-distribute-patterns
-fno-loop-interchange -fno-loop-unroll-and-jam -fno-split-paths
-fno-tree-slp-vectorize -fno-vect-cost-model -fno-tree-partial-pre
-fno-peel-loops -fno-ipa-cp-clone -fno-split-loops
The reproducer adds all the above to the command and still generates the
failure.
The problem is rare
No other SPEC CPU 2017 benchmarks failed for me on SPARC Linux with GCC 9.1.
Within the failing benchmark, 479 modules were built, and they had
29,623 std instructions:
$ ls *.s | wc -l
479
$ cat *s | expand |grep -c " std"
29623
$
and only one with a bad floating point double register:
$ cat *s | expand |grep " std" | tr -s ' ' | cut -f1 -d, | sort |
uniq
std %f0
std %f10
std %f12
std %f14
std %f16
std %f18
std %f2
std %f20
std %f22
std %f24
std %f25 <-----
std %f26
std %f28
std %f30
std %f32
std %f34
std %f36
std %f38
std %f4
std %f40
std %f42
std %f44
std %f46
std %f48
std %f50
std %f52
std %f54
std %f56
std %f58
std %f6
std %f60
std %f62
std %f8
$
$ grep std *s | grep f25
module_cu_nsas.fppized.s: std %f25, [%fp+1799]
$
To reproduce:
$ ls
illegal_operand.tar.xz
$ xz -dc illegal_operand.tar.xz | tar -xvf -
illegal_operand/
illegal_operand/readme.txt
illegal_operand/module_cu_nsas.F
illegal_operand/doit.sh
$ cd illegal_operand
$
Edit 'doit.sh' for your paths, and then:
$ ./doit.sh
This command using -O3 is expected to fail with gcc 9.1:
/export/GCC/gcc-9.1.0/bin/gfortran -ffree-form -nocpp -O3 -m64 -c -o
module_cu_nsas.o -v -save-temps -g -fstack-arrays -ffinite-math-only
-mcpu=niagara3 module_cu_nsas.F
press enter to continue
GNU assembler version 2.32 (sparc64-unknown-linux-gnu) using BFD version
(johnh-16-May-2019) 2.32
module_cu_nsas.s: Assembler messages:
module_cu_nsas.s:9061: Error: Illegal operands
press enter to continue
This command still uses -O3, but turns off many of its components. It is
expected to still fail with gcc 9.1
/export/GCC/gcc-9.1.0/bin/gfortran -ffree-form -fno-inline-functions
-fno-predictive-commoning -fno-gcse-after-reload
-fno-tree-loop-distribution -fno-tree-loop-distribute-patterns
-fno-loop-interchange -fno-loop-unroll-and-jam
-fno-split-paths -fno-tree-slp-vectorize -fno-vect-cost-model
-fno-tree-partial-pre -fno-peel-loops -fno-ipa-cp-clone
-fno-split-loops -nocpp -O3 -m64 -c -o module_cu_nsas.o -v -save-temps -g
-fstack-arrays -ffinite-math-only -mcpu=niagara3 module_cu_nsas.F
press enter to continue
GNU assembler version 2.32 (sparc64-unknown-linux-gnu) using BFD version
(johnh-16-May-2019) 2.32
module_cu_nsas.s: Assembler messages:
module_cu_nsas.s:9087: Error: Illegal operands
$