There are two cases: ### Case1: ```csharp static bool Case1(int x) => x < 0; // probably also `x >= 0` ``` current codegen: ```asm cmp w0, #0 cset x0, lt ``` expected codegen: ```asm lsr x0, w0, #31 ``` x86-related PR: https://github.com/dotnet/runtime/pull/35627 ### Case2 (jump condition): ```csharp static void Case2(int a) { if (a < 0) // and "a >= 0" Foo(); } ``` current codegen: ```asm cmp w0, #0 bge G_M29168_IG04 ``` expected codegen: ```asm tbnz w0, #31, G_M29168_IG04 ``` NOTE: for the second case we already have an optimization for x==0 -> tb(n)z so should be easy to extend. /cc @kunalspathak @echesakovMSFT category:cq theme:codegen skill-level:intermediate cost:medium impact:medium
Activity
echesakov commentedon Oct 16, 2020
Thanks @EgorBo for opening this. I will add the optimizations to .NET 6 Arm64 "Epic" issue I am working right now as a potential work in .NET 6.