ARM64: Improve encoding selection for CodeGen::instGen_Set_Reg_To_Imm
For some large negative constants (and other cases) we can encode the constant using fewer instructions than we currently use.
For example the constant 0xffff ff29 406b 2a1b can be encoded using three instructions, provided we start by using a movn instruction.
Generating: N041 ( 1, 1) [000047] ------------- \* const long 0xffffff29406b2a1b REG x8 $c5
IN000f: movn x8, #0xd5e4
IN0010: movk x8, #0x406b LSL dotnet/coreclr#16
IN0011: movk x8, #0xff29 LSL dotnet/coreclr#32
I have a fix for this issue
I think it's already implemented/merged as of today. I also think we could emit mostly one instruction (4 byte) that loads constant from Jit read-only data (8 byte). It's arguable depending on cache-misses, but when the same constant is repeated (like GC cookie check), loading constant from memory could be better.
No I don't believe that I checked this in yet. I will submit a PR this week, with my changes for this.
@briansull @kyulee1 @jashook Is this still an open issue?
My change handled large negative constants in a way that reduced the number of instructions from 4 to 3. I don't think that we ever checked this in as it was low priority in term of perf impact.