0

One pass run by the compiler when optimising in gcc is falign-loops.

Although a vague description is provided here: https://www.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/data-options/falign-loops-qalign-loops.html

It is listed as one of the optimisations occurring with the -O2 flag here: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

I have been unable to actually see it work in action with any piece of code I have tried using compiler explorer. Does anyone know how the flag functions and perhaps have some explicit examples?

Thanks

Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
  • 2
    In gcc's doc, "If n is not specified or is zero, use a machine-dependent default which is very likely to be ‘1’, meaning no alignment. The maximum allowed n option value is 65536." I believe `-O2` uses default value which is probably `1`. Please [edit] to provide your test code on godbolt. – Louis Go May 09 '22 at 07:23
  • 2
    [Could you use C inline assembly to align instructions? (without Compiler optimizations)](https://stackoverflow.com/q/72005117) shows some real examples of GCC asm output, including one where `-falign-loops=16` produced a `.p2align 4,,10` / `.p2align 3` before a loop. (Note that Godbolt filters directives by default; perhaps that was your problem? Either way, possible duplicate, unless Louis's comment is the key instead.) – Peter Cordes May 09 '22 at 08:17

0 Answers0