[COMMITTED] Docs: Address -fivopts, -O0, and -Q confusion [PR71094]

Message ID 20250415192107.1129054-1-sloosemore@baylibre.com
State Committed
Commit d91aab4dd6814ca54c211a93fec3f072745a52c4
Headers
Series [COMMITTED] Docs: Address -fivopts, -O0, and -Q confusion [PR71094] |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap fail Patch failed to apply

Commit Message

Sandra Loosemore April 15, 2025, 7:21 p.m. UTC
  There's a blurb at the top of the "Optimize Options" node telling
people that most optimization options are completely disabled at -O0
and a similar blurb in the entry for -Og, but nothing at the entry for
-O0.  Since this is a continuing point of confusion it seems wise to
duplicate the information in all the places users are likely to look
for it.

gcc/ChangeLog
	PR tree-optimization/71094
	* doc/invoke.texi (Optimize Options): Document that -fivopts is
	enabled at -O1 and higher.  Add blurb about -O0 causing GCC to
	completely ignore most optimization options.
---
 gcc/doc/invoke.texi | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Patch

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b99da94dca1..0b6644b0315 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -12746,6 +12746,7 @@  complexity than at @option{-O}.
 -fipa-pure-const
 -fipa-reference
 -fipa-reference-addressable
+-fivopts
 -fmerge-constants
 -fmove-loop-invariants
 -fmove-loop-stores
@@ -12854,6 +12855,13 @@  by @option{-O2} and also turns on the following optimization flags:
 Reduce compilation time and make debugging produce the expected
 results.  This is the default.
 
+At @option{-O0}, GCC completely disables most optimization passes;
+they are not run even if you explicitly enable them on the command
+line, or are listed by @option{-Q --help=optimizers} as being enabled by
+default.  Many optimizations performed by GCC depend on code analysis
+or canonicalization passes that are enabled by @option{-O}, and it would
+not be useful to run individual optimization passes in isolation.
+
 @opindex Os
 @item -Os
 Optimize for size.  @option{-Os} enables all @option{-O2} optimizations
@@ -14306,6 +14314,7 @@  Enabled by default at @option{-O1} and higher.
 @item -fivopts
 Perform induction variable optimizations (strength reduction, induction
 variable merging and induction variable elimination) on trees.
+Enabled by default at @option{-O1} and higher.
 
 @opindex ftree-parallelize-loops
 @item -ftree-parallelize-loops=n