RyuJIT should be able to discover and emit bool-to-int conversions in the most efficient way. #4399
Labels
area-CodeGen-coreclr
CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
enhancement
Product code improvement that does NOT require public API changes/additions
optimization
tenet-performance
Performance related issue
Milestone
Usual ways to convert boolean into integers in C# are:
While the latest is the most efficient, it is a pain to use. The other two which are used in plenty places including the Framework itself could emit a very efficient assembly code instead of the standard method call (as of right now).
Differences in performance are huge:
// BenchmarkDotNet=v0.7.6.0
// OS=Microsoft Windows NT 6.2.9200.0
// Processor=Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz, ProcessorCount=4
// CLR=MS.NET 4.0.30319.42000, Arch=64-bit [RyuJIT]
Common: Type=Jit_BoolToInt Mode=Throughput Platform=X64 .NET=Current
Repro: https://gist.github.com/redknightlois/c1ae5ddc6f73c2e53c9b
category:cq
theme:optimization
skill-level:intermediate
cost:small
The text was updated successfully, but these errors were encountered: