-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
area-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 SuperPMItenet-performancePerformance related issuePerformance related issue
Milestone
Description
Description
static void M1(object o) {
if ((o ??= new object()) is null) throw new Exception();
}
static void M2(object o) {
if ((o = new object()) is null) throw new Exception();
}
static void M3(int i) {
if (i < 0) i = 0;
if (i < 0) throw new Exception();
}
static void M4(object o) {
}While the JIT can optimize M2(almost, but still curiously worse than M4) and M3 to a nop, it cannot optimize M1 similarly.
Found while discussing #75936.
Configuration
sharplab says "Core CLR 6.0.822.36306 on amd64".
I also tried 7.0.100-rc.1.22431.12 on amd64. The codegen for M1 was not really better.
Regression?
Probably not.
Metadata
Metadata
Assignees
Labels
area-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 SuperPMItenet-performancePerformance related issuePerformance related issue