https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80980
Bug ID: 80980 Summary: -Os generates larger code than -O1 because loop is not removed Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tkoenig at gcc dot gnu.org Target Milestone: --- $ cat foo.f90 program main integer :: i do i=1,1 print *,i end do end program main $ gfortran -o os.s -S -Os foo.f90 $ gfortran -o o1.s -S -O1 foo.f90 $ wc -l os.s 82 os.s $ wc -l o1.s 63 o1.s This is probably due to -Os not removing the loop. The -fdump-tree-optimized dump shows for -Os <bb 2> [15.00%]: i = 1; <bb 3> [100.00%]: i.2_1 = i; if (i.2_1 > 1) goto <bb 5>; [15.00%] else goto <bb 4>; [85.00%] and for -O1 <bb 2> [15.00%]: i = 1; $ gfortran -v Es werden eingebaute Spezifikationen verwendet. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/home/ig25/lib/gcc/x86_64-pc-linux-gnu/8.0.0/lto-wrapper Ziel: x86_64-pc-linux-gnu Konfiguriert mit: ../trunk/configure --prefix=/home/ig25 --enable-languages=c,c++,fortran --enable-maintainer-mode Thread-Modell: posix gcc-Version 8.0.0 20170525 (experimental) (GCC)