-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Optimize u>=1 to u!=0 and u<1 to u==0 #25458
Conversation
|
Any diffs? |
|
@mikedn is there a doc on how to do it properly for the whole coreclr/corefx? I am only using |
|
For diffs you need jit-diff from the jitutils repository: https://github.com/dotnet/jitutils/blob/master/doc/diffs.md Running jit-diff itself shouldn't be too difficult but you need a coreclr "baseline". The docs recommend using a separate coreclr clone but I find that to be overkill. I normally just build master and save the clrjit.dll in a "base" folder and pass that to jit-diff. |
|
Here's the x64 FX diff: |
| // will still compute the same value as before | ||
| tree->SetOper(oper, GenTree::PRESERVE_VN); | ||
| cns2->gtIntCon.gtIconVal = 0; | ||
| SET_OPER: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better replace it to outside of else if (!tree->IsUnsigned() && cns2->IsIntegralConst(-1)) scope and also its end of if (op2->gtOper == GT_CNS_INT)?
|
@dotnet/jit-contrib |
sandreenko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the change looks good, thank you!
Sorry , it took me longer than I expected to reach that PR.
Could you please rebase/fix the conflicts and we will merge that?
|
@sandreenko sure! |
ac7842b to
55619df
Compare
…comp-fixes # Conflicts: # src/jit/morph.cpp
55619df to
5ea3065
Compare
|
@EgorBo could you please clone https://github.com/dotnet/jitutils, run bootstrap.cmd and then run jit-format to fix the formatting errors, like: |

JIT already applies these tricks for signed types. This PR adds support for unsigned (extends existing logic). The diff looks big because I removed the surrounding if-else block
; Method MyTests:C1(int):bool:this G_M54558_IG02: test edx, edx setg al movzx rax, al ; Total bytes of code: 9 ; Method MyTests:C2(int):bool:this G_M54557_IG02: test edx, edx setle al movzx rax, al ; Total bytes of code: 9 ; Method MyTests:C3(int):bool:this G_M54556_IG02: test edx, edx setl al ; LLVM generates shr eax, 31 movzx rax, al ; Total bytes of code: 9 ; Method MyTests:C4(int):bool:this G_M54555_IG02: test edx, edx setge al movzx rax, al ; Total bytes of code: 9 ; Method MyTests:UC1(int):bool:this G_M19883_IG02: - cmp edx, 1 - setae al + test edx, edx + setne al movzx rax, al -; Total bytes of code: 10 +; Total bytes of code: 9 ; Method MyTests:UC2(int):bool:this G_M19880_IG02: - cmp edx, 1 - setb al + test edx, edx + sete al movzx rax, al -; Total bytes of code: 10 +; Total bytes of code: 9/cc: @mikedn