JIT: Optimize "X ^ 0" to "X"
Current implementation emits:
8B4510 mov eax, dword ptr [rbp+10H]
83F000 xor eax, 0
I suppose it can be simplified to
8B4510 mov eax, dword ptr [rbp+10H]
https://godbolt.org/z/57fh1v6PK
I made a quick research and folded it in the lowering phase. The diffs are quite small, but the folding may be useful.
before.txt after.txt diff_summary.6.md
@EgorBo, @SingleAccretion I would be happy to know your opinion if it is worth it to implement this optimization.
Tagging subscribers to this area: @JulieLeeMSFT See info in area-owners.md if you want to be subscribed.
Issue Details
Current implementation emits:
8B4510 mov eax, dword ptr [rbp+10H]
83F000 xor eax, 0
I suppose it can be simplified to
8B4510 mov eax, dword ptr [rbp+10H]
https://godbolt.org/z/57fh1v6PK
I made a quick research and folded it in the lowering phase. The diffs are quite small, but the folding may be useful.
before.txt after.txt diff_summary.6.md
@EgorBo, @SingleAccretion I would be happy to know your opinion if it is worth it to implement this optimization.
| Author: | SkiFoD |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
https://godbolt.org/z/57fh1v6PK
nit: here is the updated link with optimization flags: https://godbolt.org/z/rG3cMKr5q
@EgorBo, @SingleAccretion I would be happy to know your opinion if it is worth it to implement this optimization.
why not if it produces diffs 🙂
Have you measured the diffs if it's done in morph instead? I guess it should be a pretty straightforward change in morph.
E.g. I believe we already have x * 0 there
@EgorBo, @SingleAccretion I would be
happy to know your opinion if it is worth it to implement this optimization.
why not if it produces diffs 🙂
Have you measured the diffs if it's done in morph instead? I guess it should be a pretty straightforward change in morph. E.g. I believe we already have
x * 0there
I tried to implement it in morph at first, it produced these regressions (diff_summary.3.md)
However, I think it could happen because I missed something.
I moved the optimization to morph phase. Here are asmdiffs for x64 diff_summary.10.md I couldn't get rid of the regressions. There are 190 of them, which doesn't feel right to me.
@SkiFoD, the code complete for .NET 7 is July 11th. Do you think you can complete this before that? If not, we can move this to .NET 8.
I couldn't get rid of the regressions. There are 190 of them, which doesn't feel right to me
Examples of the regressions would be beneficial (that is the actual assembly before/after). Often times regressions may simply be the JIT being able to kick in additional optimizations once the IR has simplified.
@JulieLeeMSFT @tannergooding Hey everyone. The code has been already merged here https://github.com/dotnet/runtime/pull/65072