Conversation
|
Thanks for the contribution. Did you actually notice any performance improvement with this optimization? 😄 While your change is accurate I doubt it really affected anything, as this is the type of optimization that the compiler would easily do by itself. |
It isn't strictly equal so the assembler optimizer cannot change it (also I don't think the assembler has any optimizations) , as it doesn't check The O flag (overflow) while jle does but as no overflow happens (it is a positive signed int) it is 1 less instruction for jle vs 2 seperate jumps. Performance wise I did a small test but it was noise and I didn't notice anything but I had background apps running so. But for readability I think it is worth it. |
|
I also tried rewriting the file to use no volatile registers, but I don't know whether it is readable using less instructions and stack in the process. 14f7521#diff-6bb1a1e324035a147c6f845c43b35e5a302837b28321eea42cf6124ed16fdb03 |
|
As long as the code comments explain at a high level what the assembly instructions are doing it should be OK. |
|
Have you took a look at the diff? Should I make a new pr for it or should I update this pr? |
101488a to
4f1dd02
Compare
I tested this change by running the as_test suite, and all tests passed.
While learning x64 assembly for a compiler project (with the goal of contributing more to AngelScript, as I really enjoy the language) and studying calling conventions, I spent time reading through AngelScript's implementation. It was a great learning resource,
and while doing so I noticed this tiny small optimization.I tried rewriting the code to not use any non volatile registers saving lots of pops and pushes. I did some small tests that called empty functions with 1 int and 4 int and 8 int and 1 float, 4 float and 8 float args and it seems to be faster by about 10%-15% but this is not representative of the real world as this is just calling an empty function it got slower at calling 0 arg functions since i removed the branch though but I don't think they are that common to special case.
Resources used:
https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#callercallee-saved-registers