If your project consists of multiple source files (as most projects do), you may also look at Link Time Optimization (commonly abbreviated LTO).
It makes extra optimizations between objects (at link time, as the name suggests).
You may look for a specific "Link time optimization" / "LTO" option in your IDE, or look for a place to add compiler flags.
If your compiler is GCC or Clang based, you may add the
-flto flag during both compilation and link time (Both CFLAGS and LDFLAGS if relevant).
This can optimize out whole blocks of code (inside functions) which aren't called, or optimize them for a specific input pattern.
Note that if you use the standard library, you need to make sure you compile that with LTO to get big savings.
You may read more about LTO here: https://en.wikipedia.org/wiki/Interprocedural_optimization
And an example from the Linux kernel here: https://lwn.net/Articles/744507/