Bin. Cheng wrote: > Quoting from GCCINT, section "9.5 RTL passes": > "When optimizing for size, GCSE is done using Morel-Renvoise Partial > Redundancy Elimination, with the exception that it does not try to > move invariants out of loops—that is left to the loop optimization > pass. If MR PRE GCSE is done, code hoisting (aka unification) is also > done, as well as load motion." > > While the pass gate function is as below: > static bool > gate_rtl_pre (void) > { > return optimize > 0 && flag_gcse > && !cfun->calls_setjmp > && optimize_function_for_speed_p (cfun) > && dbg_cnt (pre); > } > > It seems the PRE pass is disabled when not optimizing for speed. > Doesn't this conflict with the documentation, which says > Morel-Renvoise PRE will be used when optimizing for size.
The documentation should say "When *not* optimizing for size..." . But this piece of documentation seems to be in need of some TLC anyway: * hoisting is not enabled (or used to be not enabled, not sure what it's like now) when not optimizing for size. hoisting is enabled with -Os, PRE is disabled. * MR PRE was replaced with edge-based lazy code motion even before GCC 3.0 * loop code motion is now done on GIMPLE way before RTL PRE * ... (probably half a dozen more issues) ... If you file a PR, I'll update the documentation for the old gcse.c passes (HOIST, PRE, CPROP). Ciao! Steven