Jordan Frank via llvm-dev
2020-Sep-06 23:12 UTC
[llvm-dev] Where's the optimiser gone? Or: who reviews the code you ship?
In my experience, all humans strive for self-improvement. However, such endeavors can be difficult without good feedback. Thus, I present to you, my friend Stefan, a version of your contribution to our mailing list in which the author does not come across as a condescending <explicative deleted>, and whose contents holds the possibility of being taken in good faith and acted upon. --- Subject: Potential opportunity for generating more efficient code. Hi folks, Thank you for all the hard work you do to produce LLVM. I am finding it helpful in my work. I believe I may have identified instances of suboptimal code being generated by the compiler. While digging in and understanding the cause of this issue or proposing a fix is well outside both my interests and skillset, I hope that in highlighting the issue I might spur someone's interest and potentially lead to improvements to this awesome project. I have observed the following sequence of instructions in 4 places in the builtins library: mov eax, 0 cmp ecx, edx jb @f cmp edx, ecx mov eax, 1 adc eax, 0 @@ ret which I believe could be more compactly expressed as: xor eax, eax cmp edx, ecx ja @f adc eax, 1 @@ ret I believe this code saves 10 bytes and 2 instructions. I could also be making incorrect assumptions about why the former code is produced (my assumption being incompetent developers), in which case I would love the opportunity to learn and grow through an explanation. I could also have tried to produce sample code or provide an explanation of how I identified this, but, to be honest, my intention here is not to help but to attempt to embarrass the developers on this project as I felt I was treated unfairly when previously trolling this mailing list. Best, Stefan Kanthak 73rd-most prolific Windows bug report in 2016. --- Best wishes, Jordan Frank, Whom does not enjoy being subjected to the repeated trolling of this list by OP. On 9/6/20, 10:07 AM, "llvm-dev on behalf of Stefan Kanthak via llvm-dev" <llvm-dev-bounces at lists.llvm.org on behalf of llvm-dev at lists.llvm.org> wrote: Hi @ll, who can tell me (or the world) why an optimising compiler emits the code sequence shown in the left column (found 4x in the "builtins" library)? In the middle column the expected code sequence. mov eax, 0 # xor eax, eax # -3 bytes cmp ecx, edx # cmp edx, ecx jb @f # ja @f cmp edx, ecx # # -2 bytes mov eax, 1 # # -5 bytes adc eax, 0 # adc eax, 1 # -2 insns @@: # @@: ret # ret Stefan --