-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Follow-up to #106419 (discussion). When casting, for example, a ulong to a float, Roslyn emits the following IL:
conv.r.un
conv.r4
Which is then imported by the JIT as a ulong -> float -> double cast sequence. Casting in two steps can produce slightly different results from casting directly to float, which is also why it isn't always correct to just morph the above IR into ulong -> float. Ideally, we would differentiate between ulong -> float and ulong -> double -> float during importation, and create IR that accurately models each pattern.
Similarly, constant folding should model each pattern correctly. In other words, to model ulong -> float, we should cast the constant directly to float, and rely on MSVC/Clang/GCC/etc. to emit the correct sequence.
cc @dotnet/jit-contrib