runtime icon indicating copy to clipboard operation
runtime copied to clipboard

ARM64: Improve encoding selection for CodeGen::instGen_Set_Reg_To_Imm

Open briansull opened this issue 10 years ago • 6 comments

For some large negative constants (and other cases) we can encode the constant using fewer instructions than we currently use.

briansull avatar Feb 08 '16 23:02 briansull

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

briansull avatar Feb 08 '16 23:02 briansull

I have a fix for this issue

briansull avatar Feb 23 '16 17:02 briansull

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.

kyulee1 avatar Jul 06 '16 17:07 kyulee1

No I don't believe that I checked this in yet. I will submit a PR this week, with my changes for this.

briansull avatar Jul 06 '16 19:07 briansull

@briansull @kyulee1 @jashook Is this still an open issue?

sdmaclea avatar May 08 '17 16:05 sdmaclea

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.

briansull avatar May 08 '17 17:05 briansull