gaul / x86lint

Examine x86 machine code to find suboptimal encodings and sequences

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

INC vs. ADD RAX, 1 and DEC vs. SUB RAX, 1

gaul opened this issue · comments

This has some nuance since INC and DEC partially update flags but these can be the same speed but smaller than ADD RAX, 1 and SUB RAX, 1 on modern CPUs:

https://stackoverflow.com/a/36510865

and much faster on one AMD variant:

https://msrc-blog.microsoft.com/2021/01/11/building-faster-amd64-memset-routines/#post-12548:~:text=Mysterious%20AMD%2DFX%208100%20Perf%20Regression