I've been browsing through the GCC source code and I've been stumped on how to extract these. Can anyone provide a list or information on how to extract these peepholes (assembly rewrite optimizations)?
GCC code: https://github.com/gcc-mirror/gcc
Edit: To clarify, a "peephole" is defined to be a find and replace pattern with some associated side conditions for the rewrite to be valid (often just some register/flags liveness information).
It is really off-topic since too broad here.
You might look into my documentation page of MELT; it has several useful references (notably the Indian GCC resource center), and most of the slides I wrote contain reference and tutorial material...
Most of GCC optimizations happen in the (target & source neutral) middle-end layers, not in the backend.
And peephole optimization does not means much (precisely) these days, and most of the optimization power of GCC does not come from it.
Look in the various
*.md
files and search fordefine_peephole
.For example:
gcc/config/i386/i386.md
contains (among many others):The relevant documentation is in the GCC Internals Manual
https://gcc.gnu.org/onlinedocs/gccint/Peephole-Definitions.html#Peephole-Definitions