The head of the gomp branch reports an ICE when trying to compile the snippet below: template<typename T> struct Healpix_Map { T *map; int npix_; void Import_nograde (const Healpix_Map<T> &orig) { #pragma omp parallel { int m; #pragma omp for schedule (dynamic) for (m=0; m<npix_; ++m) map[m] = orig.map[m]; } } }; void foo(Healpix_Map<int> &a, Healpix_Map<int> &b) { a.Import_nograde(b); } ~/tmp>g++ -v -c -fopenmp test.cc Using built-in specs. Target: i686-pc-linux-gnu Configured with: /scratch/gompcc/configure --quiet --prefix=/scratch/ugccgomp --enable-languages=c++,f ortran --with-gmp=/afs/mpa/data/martin/mygmp Thread model: posix gcc version 4.1.0-gomp-20050608-branch 20051109 (experimental) (merged 20051109) /scratch/ugccgomp/libexec/gcc/i686-pc-linux-gnu/4.1.0-gomp-20050608-branch/cc1plus -quiet -v -D_GNU_S OURCE test.cc -quiet -dumpbase test.cc -mtune=pentiumpro -auxbase test -version -fopenmp -o /tmp/ccCSV 0EZ.s ignoring nonexistent directory "/scratch/ugccgomp/lib/gcc/i686-pc-linux-gnu/4.1.0-gomp-20050608-branch /../../../../i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /scratch/ugccgomp/lib/gcc/i686-pc-linux-gnu/4.1.0-gomp-20050608-branch/../../../../include/c++/4.1.0- gomp-20050608-branch /scratch/ugccgomp/lib/gcc/i686-pc-linux-gnu/4.1.0-gomp-20050608-branch/../../../../include/c++/4.1.0- gomp-20050608-branch/i686-pc-linux-gnu /scratch/ugccgomp/lib/gcc/i686-pc-linux-gnu/4.1.0-gomp-20050608-branch/../../../../include/c++/4.1.0- gomp-20050608-branch/backward /usr/local/include /scratch/ugccgomp/include /scratch/ugccgomp/lib/gcc/i686-pc-linux-gnu/4.1.0-gomp-20050608-branch/include /usr/include End of search list. GNU C++ version 4.1.0-gomp-20050608-branch 20051109 (experimental) (merged 20051109) (i686-pc-linux-gn u) compiled by GNU C version 4.1.0-gomp-20050608-branch 20051109 (experimental) (merged 20051109) . GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: d8a8851eea700f35b0082059a490739d test.cc: In member function 'void Healpix_Map<T>::Import_nograde(const Healpix_Map<T>&) [with T = int] ': test.cc:9: internal compiler error: in expand_expr_real_1, at expr.c:6681 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
> gcc version 4.1.0-gomp-20050608-branch 20051109 (experimental) (merged 20051109) BTW, it appears as if the compiler datestamp is not correctly updated on the gomp branch (it says 20051109, but there have been commits to the branch after that date).
The problem here is a mismatch between determine_parallel_type in gimplify.c and omp-low.c. During gimplification, it is not considered to be a combined parallel loop, because OMP_PARALLEL's body contains a DECL_EXPR (for m variable) before OMP_FOR. But during omp lowering, that DECL_EXPR is already gone and therefore the loop is handled as a combined loop. But there are statements before the FOR_STMT inside of OMP_FOR, and those are moved into a wrong context when doing a parallel loop. Maybe we should ignore (some?) DECL_EXPRs in determine_parallel_type, maybe we need to note the combined parallel status in OMP_PARALLEL's flags.
Some more information: - I didn't encounter the bug about a week ago - on x86_64 with checking disabled, I get guest@mpac-7:~/martin> g++ -c -v -fopenmp test.cc Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: /home/guest/martin/gompcc/configure --quiet --prefix=/home/guest/martin/ugccgomp --disable-checking --enable-languages=c++,fortran --with-gmp=/home/guest/martin/mygmp Thread model: posix gcc version 4.1.0-gomp-20050608-branch 20051109 (experimental) (merged 20051109) /home/guest/martin/ugccgomp/libexec/gcc/x86_64-unknown-linux-gnu/4.1.0-gomp-20050608-branch/cc1plus -quiet -v -D_GNU_SOURCE test.cc -quiet -dumpbase test.cc -mtune=k8 -auxbase test -version -fopenmp -o /tmp/ccH4pPJ3.s ignoring nonexistent directory "/home/guest/martin/ugccgomp/lib/gcc/x86_64-unknown-linux-gnu/4.1.0-gomp-20050608-branch/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/guest/martin/ugccgomp/lib/gcc/x86_64-unknown-linux-gnu/4.1.0-gomp-20050608-branch/../../../../include/c++/4.1.0-gomp-20050608-branch /home/guest/martin/ugccgomp/lib/gcc/x86_64-unknown-linux-gnu/4.1.0-gomp-20050608-branch/../../../../include/c++/4.1.0-gomp-20050608-branch/x86_64-unknown-linux-gnu /home/guest/martin/ugccgomp/lib/gcc/x86_64-unknown-linux-gnu/4.1.0-gomp-20050608-branch/../../../../include/c++/4.1.0-gomp-20050608-branch/backward /usr/local/include /home/guest/martin/ugccgomp/include /home/guest/martin/ugccgomp/lib/gcc/x86_64-unknown-linux-gnu/4.1.0-gomp-20050608-branch/include /usr/include End of search list. GNU C++ version 4.1.0-gomp-20050608-branch 20051109 (experimental) (merged 20051109) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.1.0-gomp-20050608-branch 20051109 (experimental) (merged 20051109). GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 77b131b8a7d189e4ba7ca911c1f9b018 test.cc: In member function รข: test.cc:10: error: insn does not satisfy its constraints: (insn 14 13 38 (set (reg:DI 0 ax [orig:58 D.2187 ] [58]) (sign_extend:DI (reg:SI 77 [ D.2153 ]))) 115 {extendsidi2_rex64} (nil) (nil)) test.cc:10: internal compiler error: in extract_constrain_insn_cached, at recog.c:2002 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Working on this.
Here's a shorter testcase without templates: ========================================== void foo() { #pragma omp parallel { int i, N; #pragma omp for schedule (dynamic) for (i=0; i<N; ++i) ; } } ========================================== The bug only affects the C++ frontend. The above testcase compiles fine with the C frontend.
Subject: Bug 24849 Author: dnovillo Date: Sat Nov 19 15:18:08 2005 New Revision: 107220 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107220 Log: PR 24849 * omp-low.c (determine_parallel_type): Do not handle OMP_FOR. testsuite/ PR 24849 * g++.dg/gomp/pr24849.C: New test. * gcc.dg/gomp/for-19.c: XFAIL. * gcc.dg/gomp/for-18.c: XFAIL. Added: branches/gomp-20050608-branch/gcc/testsuite/g++.dg/gomp/pr24849.C Modified: branches/gomp-20050608-branch/gcc/ChangeLog.gomp branches/gomp-20050608-branch/gcc/omp-low.c branches/gomp-20050608-branch/gcc/testsuite/ChangeLog.gomp branches/gomp-20050608-branch/gcc/testsuite/gcc.dg/gomp/for-18.c branches/gomp-20050608-branch/gcc/testsuite/gcc.dg/gomp/for-19.c
Workaround applied. The actual solution separates lowering from optimization, once all the OMP directives are lowered to a language-independent form, we can apply the combined parallel+loop optimization without running into these odd corners. I need a few more days to finish implementing this separation. In the meantime, we can live without this optimization.