3 ms·
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 hostil
by chasil 1y 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 1y agoYou 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.
- chasil 1y agoThanks, I'll give it a try.
- o11c 1y agoObviously 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.
- wat10000 1y agoI don't have gcc handy, but this bit of code pretty easily gets clang to use several of them: int f(int **x) { int *a = x[0]; int *b = x[1]; int *c = x[2]; int *d = x[3]; puts("hello"); return *a + *b + *c + *d; }