Repro steps
Consider this function:
Now look at the generated IL code:
Expected behavior
IL_0000: ldarg.0
IL_0001: ldc.i4.1
IL_0002: conv.u8
IL_0003: add
IL_0004: ret
This is what C# generates. Generally, it should emit ldc.i4.#/ldc.i4.s/ldc.i4 with a conv, and only if the number is even bigger should it emit ldc.i8.
Actual behavior
IL_0000: ldarg.0
IL_0001: ldc.i8 1
IL_000a: add
IL_000b: ret
The function's IL code takes 12 bytes, instead of 5, as expected. This might interfere with the JIT's decision to inline small functions.
Known workarounds
let inc x = x + (uint64 1)
Related information
This happens only with uint64 literals. Literals of all other integral types (including signed int64) emit optimal code.
Repro steps
Consider this function:
Now look at the generated IL code:
Expected behavior
This is what C# generates. Generally, it should emit
ldc.i4.#/ldc.i4.s/ldc.i4with aconv, and only if the number is even bigger should it emitldc.i8.Actual behavior
The function's IL code takes 12 bytes, instead of 5, as expected. This might interfere with the JIT's decision to inline small functions.
Known workarounds
Related information
This happens only with
uint64literals. Literals of all other integral types (including signedint64) emit optimal code.