▲ | chasil 4 hours ago | |||||||
The times that I have used "gcc -S" on my code, I have never seen the additional registers used. I understand that r8-r15 require a REX prefix, which is hostile to code density. I've never done it with -O2. Maybe that would surprise me. | ||||||||
▲ | astrange 3 hours ago | parent | next [-] | |||||||
You should be able to see it. REX prefixes cost a lot less than register spills do. If you mean literally `gcc -S`, -O0 is worse than not optimized and basically keeps everything in memory to make it easier to debug. -Os is the one with readable sensible asm. | ||||||||
| ||||||||
▲ | o11c 2 hours ago | parent | prev [-] | |||||||
Obviously it depends on how many live variables there are at any point. A lot of nasty loops have relatively few non-memory operands involved, especially without inlining (though even without inlining, the ability to control ABI-mandated spills better will help). But it's guaranteed to use `r8` and `r9` for for a function that takes 5 and 6 integer arguments (including unpacked 128-bit structs as 2 arguments), or 3 and 4 arguments (not sure about unpacking) for Microsoft. And `r10` is used if you make a system call on Linux. |