Another case of bad compilation time. Memory consumption is also very heavy.
I believe this is different from PR 18937 and PR 18938, because - a g77 based on gcc 3.3 does not have this problem $ cat spaghetti-if #! /usr/bin/perl $last = shift; for ($i=2; $i<=$last; $i++) { push(@lines, sprintf("%5d i=i+1\n if (i-%d) %d, %d, %d\n", $i, $i, $i-1, $i, $i+1)); } for ($i=0; $i<=$last; $i++) { $j = int(rand($last)); $temp = $lines[$i]; $lines[$i] = $lines[$j]; $lines[$j] = $temp; } print " i=0\n"; print " 1 goto 2\n"; print @lines; printf "%5d continue\n",$last+1; print " print *,i\n"; print " end\n"; $ perl spaghetti-if 1000 > spaghetti-if.f $ time gfortran spaghetti-if.f real 0m3.687s user 0m3.620s sys 0m0.030s $ $ perl spaghetti-if 3000 > spaghetti-if.f $ time gfortran spaghetti-if.f real 0m41.834s user 0m39.119s sys 0m0.144s $ ./spaghetti-if 5000 > spaghetti-if.f $ time gfortran spaghetti-if.f real 2m7.288s user 2m6.634s sys 0m0.213s $ ./a.out 5001 $ time g77 spaghetti-if.f real 0m10.930s user 0m10.316s sys 0m0.104s $ perl spaghetti-if 4 i=0 1 goto 2 4 i=i+1 if (i-4) 3, 4, 5 2 i=i+1 if (i-2) 1, 2, 3 3 i=i+1 if (i-3) 2, 3, 4 5 continue print *,i end -- Summary: exponential (?) compile-time behavior with many arithmetic if statements Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Thomas dot Koenig at online dot de CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18943