On 4/22/20 4:01 PM, Erick Ochoa wrote:
Hello,
Does anyone know if the following text from the GCC internals [0] is outdated?
-O3
Optimize yet more. -O3 turns on all optimizations specified by -O2 and
also turns on the following optimization flags:
-fgcse-after-reload
-fipa-cp-clone
-floop-interchange
-floop-unroll-and-jam
-fpeel-loops
-fpredictive-commoning
-fsplit-paths
-ftree-loop-distribute-patterns
-ftree-loop-distribution
-ftree-loop-vectorize
-ftree-partial-pre
-ftree-slp-vectorize
-funswitch-loops
-fvect-cost-model
-fversion-loops-for-strides
I ask because I have an optimization pass that interacts poorly with -O3, but
compiles and runs correctly with -O2.
I'm trying to find which individual (or combination of optimizations) is
triggering the runtime error I'm debugging.
I tried running -O2 and manually enable all the optimizations turned on by -O3
(but without specifying -O3) and my pass runs successfully.
Note that using -O2 and enabling all options individually is not equal to -O3.
There are some global decisions
done based on optimization level.
For a difference, you can do:
$ gcc --help=optimize -Q -O2 > /tmp/O2
$ gcc --help=optimize -Q -O3 > /tmp/O3
$ diff -U 0 /tmp/O2 /tmp/O3
--- /tmp/O2 2020-04-22 16:19:54.123495072 +0200
+++ /tmp/O3 2020-04-22 16:19:56.903467468 +0200
@@ -54 +54 @@
- -fgcse-after-reload [disabled]
+ -fgcse-after-reload [enabled]
@@ -73 +73 @@
- -fipa-cp-clone [disabled]
+ -fipa-cp-clone [enabled]
@@ -103 +103 @@
- -floop-interchange [disabled]
+ -floop-interchange [enabled]
@@ -106 +106 @@
- -floop-unroll-and-jam [disabled]
+ -floop-unroll-and-jam [enabled]
@@ -122 +122 @@
- -fpeel-loops [disabled]
+ -fpeel-loops [enabled]
@@ -126 +126 @@
- -fpredictive-commoning [disabled]
+ -fpredictive-commoning [enabled]
@@ -178,2 +178,2 @@
- -fsplit-loops [disabled]
- -fsplit-paths [disabled]
+ -fsplit-loops [enabled]
+ -fsplit-paths [enabled]
@@ -215 +215 @@
- -ftree-loop-distribution [disabled]
+ -ftree-loop-distribution [enabled]
@@ -220 +220 @@
- -ftree-loop-vectorize [disabled]
+ -ftree-loop-vectorize [enabled]
@@ -223 +223 @@
- -ftree-partial-pre [disabled]
+ -ftree-partial-pre [enabled]
@@ -230 +230 @@
- -ftree-slp-vectorize [disabled]
+ -ftree-slp-vectorize [enabled]
@@ -242 +242 @@
- -funswitch-loops [disabled]
+ -funswitch-loops [enabled]
@@ -249,2 +249,2 @@
- -fvect-cost-model=[unlimited|dynamic|cheap] cheap
- -fversion-loops-for-strides [disabled]
+ -fvect-cost-model=[unlimited|dynamic|cheap] dynamic
+ -fversion-loops-for-strides [enabled]
Martin
So, either:
* -O3 does more than just enable these optimizations, or
* This documentation is outdated and there's something missing.
Does someone have an answer? (And if possible point to some code locations so
that I can learn where it is.) Thanks!
[0] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html