Exactly what I was going to post. Optimizations like loop unrolling slow down the N64 because keeping the code size small is the most important factor. I think even compilers of the time got this wrong, not just modern ones.
The whole thing reminds me in a fuzzy way that I don't yet fully comprehend of register-memory architecture.