I've updated this bug [Bug 81818 - aarch64 uses 2-3x memory and 2x time
of arm at -Os, -O2, -O3] with more info.
It looks to be that on ARM systems with limited RAM optimizations are
being skipped, but not on AARCH64.
Is there a way I can check this is true?
I checked all the optimizations enabled at -O2 which where not in -O1,
and checked memory usage of each. -fgcse came out the winner, using huge
amounts of memory.
Comparing -O1, -O1 -fgcse and -O2, on Rasberry Pi 3, and odroid-c2.
ARM (1Gb RAM):
gcc -O1 -c testmap.cpp
Time=2:25.26 Mem=318976 PageFaults=0
gcc -O1 -fgcse -c testmap.cpp
Time=2:42.04 Mem=554872 PageFaults=123
gcc -O2 -c testmap.cpp
Time=2:31.89 Mem=262828 PageFaults=11 <== Is this really running all
-O2 opts?
AARCH64 (1Gb RAM):
gcc -O1 -c testmap.cpp
Time=3:10.68 Mem=397248 PageFaults=3
gcc -O1 -fgcse -c testmap.cpp
Time=5:15.26 Mem=771276 PageFaults=166
gcc -O2 -c testmap.cpp
Time=11:06.06 Mem=820744 PageFaults=4266 <== blows up big time unlike ARM
AARCH64 (2Gb RAM, odroid-c2, different clock speed etc):
gcc -O1 -c ../testmap.cpp
Time=1:47.58 Mem=394896 PageFaults=0
gcc -O1 -fgcse -c ../testmap.cpp
Time=3:10.06 Mem=765460 PageFaults=0
gcc -O2 -c ../testmap.cpp
Time=3:05.06 Mem=906624 PageFaults=0 <== ok if enough RAM though
Andrew