compiler: speed up bootstrapping time by 25% (#41794)
The optimizer code is full of loop constructions and I found they're
really better to not run in interpreter.
With this PR, we create the caches of the optimizer code first and
it speeds up the succeeding bootstrapping to create the caches for
the overall inference code.
On my machine, the bootstrapping took about 80 seconds previously,
but on this PR the time is reduced to about 60 seconds.