https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69289

            Bug ID: 69289
           Summary: Compiling without --profile-generate causes longer
                    execution time (-O3)
           Product: gcc
           Version: 5.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xonar.leroux at gmail dot com
  Target Milestone: ---

Created attachment 37349
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37349&action=edit
Source

Running without --profile-generate (NOT --profile-use) causes a slowdown.

The speed script that I run simply runs the program with time output.

Effect is still present when using/not using -march=native and when using/not
using -funroll-loops

speed.sh
  1 #!/bin/zsh
  2 
  3 sudo cpupower frequency-set -g performance
  4 
  5 time ./a.out 1
  6 time ./a.out 2
  7 time ./a.out 3
  8 time ./a.out 4
  9 time ./a.out 5
 10 time ./a.out 1
 11 time ./a.out 2
 12 time ./a.out 3
 13 time ./a.out 4
 14 time ./a.out 5
 15 
 16 sudo cpupower frequency-set -g powersave

% g++ --version    
g++ (GCC) 5.3.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

% cat /proc/version 
Linux version 4.3.3-2-ARCH (builduser@tobias) (gcc version 5.3.0 (GCC) ) #1 SMP
PREEMPT Wed Dec 23 20:09:18 CET 2015

%g++ test.cpp -std=c++11 -O3 -funroll-loops -march=native --profile-generate
-Wall -Wextra
test.cpp:37:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
 int main(int argc, char** argv)

% ./speed.sh 
[sudo] password for XXXXXXX: 
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
166
./a.out 1  0.32s user 0.55s system 99% cpu 0.875 total
166
./a.out 2  0.33s user 0.54s system 100% cpu 0.870 total
166
./a.out 3  0.33s user 0.54s system 100% cpu 0.870 total
166
./a.out 4  0.33s user 0.55s system 99% cpu 0.874 total
166
./a.out 5  0.35s user 0.52s system 99% cpu 0.870 total
166
./a.out 1  0.32s user 0.55s system 99% cpu 0.867 total
166
./a.out 2  0.35s user 0.52s system 99% cpu 0.872 total
166
./a.out 3  0.32s user 0.56s system 99% cpu 0.889 total
166
./a.out 4  0.33s user 0.53s system 99% cpu 0.868 total
166
./a.out 5  0.32s user 0.55s system 100% cpu 0.873 total
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
./speed.sh  3.34s user 5.42s system 79% cpu 10.947 total

% g++ test.cpp -std=c++11 -O3 -funroll-loops -march=native -Wall -Wextra    
test.cpp:37:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
 int main(int argc, char** argv)

% ./speed.sh
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
166
./a.out 1  0.43s user 0.56s system 100% cpu 0.990 total
166
./a.out 2  0.42s user 0.57s system 99% cpu 0.983 total
166
./a.out 3  0.41s user 0.58s system 99% cpu 0.997 total
166
./a.out 4  0.47s user 0.54s system 99% cpu 1.005 total
166
./a.out 5  0.43s user 0.56s system 99% cpu 0.988 total
166
./a.out 1  0.45s user 0.54s system 99% cpu 0.991 total
166
./a.out 2  0.42s user 0.55s system 99% cpu 0.971 total
166
./a.out 3  0.39s user 0.59s system 99% cpu 0.982 total
166
./a.out 4  0.46s user 0.52s system 99% cpu 0.985 total
166
./a.out 5  0.48s user 0.51s system 99% cpu 0.985 total
Setting cpu: 0
Setting cpu: 1
Setting cpu: 2
Setting cpu: 3
Setting cpu: 4
Setting cpu: 5
Setting cpu: 6
Setting cpu: 7
./speed.sh  4.36s user 5.53s system 99% cpu 9.909 total

Reply via email to