-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Labels
JitUntriagedCLR JIT issues needing additional triageCLR JIT issues needing additional triagearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionsoptimizationtenet-performancePerformance related issuePerformance related issue
Milestone
Description
It would be useful if the JIT recognized tests like:
if ('0' <= c && c <= '9')- can be reduced to a single branch + compare + subtractif (c == ' ' || c == '\t' || c == '\r' || c == '\n')- can be reduced to 2 branches + compare + bit test (BT instruction)
The second variant is sometimes implemented using a switch/jump table (in which case is much more simpler to recognize):
switch (c) {
case ' ':
case '\t':
case '\r':
case '\n':
return true;
default:
return false;
}The reduction in number of conditional branches to 1 or 2 can make other optimizations more effective - if-conversion in particular.
Similar issue in the Roslyn repository: https://github.com/dotnet/roslyn/issues/20375
The first variant can be implemented by managed compilers but getting good code for the second is problematic if the target arch bitness is not known. Also, the BT instruction is not available in IL so it has to be simulated with shift/and/compare which the JIT has to recognize.
category:cq
theme:basic-cq
skill-level:intermediate
cost:medium
HFadeel, redknightlois, ikopylov, EgorBo, ltrzesniewski and 6 more
Metadata
Metadata
Assignees
Labels
JitUntriagedCLR JIT issues needing additional triageCLR JIT issues needing additional triagearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionsoptimizationtenet-performancePerformance related issuePerformance related issue