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

            Bug ID: 117008
           Summary: -march=native pessimization of 25% with bitset
           Product: gcc
           Version: 13.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mattreecebentley at gmail dot com
  Target Milestone: ---

Created attachment 59292
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59292&action=edit
ii file

Overview: Found a sequence of code using bitset where using -march=native and
-O2 is 25% slower than just -O2, under a Intel i7-9750H. Repeatable, also
occurs on an Intel i7-3770 but with a much lower decrease in performance
(around ~5%).

At -O2 runtime duration is ~15 seconds, -march=native;-O2 it's ~20 seconds.

Have used a PCG-based rand() in the code since regular rand() slows down the
program by 5x (difference in runtime duration between -march=native;-O2 and -O2
is still the same, but percentage change is dramatically influenced by rand
taking all the CPU time).

Code adds values to a total to prevent the code being optimized out. And yes,
.count() would've probably been more typical code. 


GCC version: 13.2.0


System type: x86_64-w64-mingw32, windows, x64


Configured with:

 ../src/configure --enable-languages=c,c++ --build=x86_64-w64-mingw32
--host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib
--prefix=/e/temp/gcc/dest --with-sysroot=/e/temp/gcc/dest
--disable-libstdcxx-pch --disable-libstdcxx-verbose --disable-nls
--disable-shared --disable-win32-registry --enable-threads=posix
--enable-libgomp --with-zstd=/c/mingw


The complete command line that triggers the bug, for -O2 only: 

C:/programming/libraries/nuwen/bin/g++.exe  -c 
"C:/programming/workspaces/march_pessimisation_demo/march_pessimisation_demo.cpp"
-O2 -std=c++23 -s -save-temps -DNDEBUG  -o
build-Release/march_pessimisation_demo.cpp.o -I. -I.
C:/programming/libraries/nuwen/bin/g++.exe -o
build-Release\bin\march_pessimisation_demo.exe @build-Release/ObjectsList.txt
-L.   -O2 -s

Or for -march=native:

C:/programming/libraries/nuwen/bin/g++.exe  -c 
"C:/programming/workspaces/march_pessimisation_demo/march_pessimisation_demo.cpp"
-O2 -march=native -std=c++23 -s -save-temps -DNDEBUG  -o
build-Release/march_pessimisation_demo.cpp.o -I. -I.
C:/programming/libraries/nuwen/bin/g++.exe -o
build-Release\bin\march_pessimisation_demo.exe @build-Release/ObjectsList.txt
-L. -s


The compiler output (error messages, warnings, etc.):

No errors or warnings.

Reply via email to