Skip to content

JIT: Model Int64/UInt64 -> Single casts without intermediate cast to Double #106646

Closed
@amanasifkhalid

Description

@amanasifkhalid

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

Metadata

Metadata

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions