You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT could further optimize "== 0" checks in Boolean logic #13573
I was able to modify the code to generate the optimized code for the two argument case.
G_M56891_IG01:
G_M56891_IG02:
or edx, ecx
sete al
movzx rax, al
G_M56891_IG03:
ret
; Total bytes of code 9, prolog size 0, PerfScore 3.40, instruction count 4, allocated bytes for code 9 (MethodHash=d88b21c4) for method Test:AreZero(int,int):bool
Unfortunately I think this may be telling you something has gone wrong -- for a change like this we would expect baseline and new jit to process the exact same number of methods.
Output like this means the new jit did not jit (or failed while trying to jit) some methods.
Beginning PMI CodeSize Diffs for System.Private.CoreLib.dll, framework assemblies
- Finished 201/271 Base 0/271 Diff [200.0 sec]Error running C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe on C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\System.Private.CoreLib.dll
1 errors compiling set.
Dasm command "jit-dasm-pmi --platform C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root --corerun C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe --jit C:\runtime2\artifacts\bin\coreclr\Windows.x64.Checked\clrjit.dll --nocopy --output c:\diffs\dasmset_13\base C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\System.Private.CoreLib.dll" returned with 1 failures
\ Finished 270/271 Base 0/271 Diff [281.7 sec]Error running C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe on C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\mscorlib.dll
1 errors compiling set.
Dasm command "jit-dasm-pmi --platform C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root --corerun C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe --jit C:\runtime2\artifacts\bin\coreclr\Windows.x64.Checked\clrjit.dll --nocopy --output c:\diffs\dasmset_13\base C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\mscorlib.dll" returned with 1 failures
\ Finished 271/271 Base 2/271 Diff [295.3 sec]Error running C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe on C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\System.Net.Http.dll
1 errors compiling set.
Dasm command "jit-dasm-pmi --platform C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root --corerun C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe --jit C:\runtime\artifacts\bin\coreclr\Windows.x64.Checked\clrjit.dll --nocopy --output c:\diffs\dasmset_13\diff C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\System.Net.Http.dll" returned with 1 failures
\ Finished 271/271 Base 195/271 Diff [479.7 sec]Error running C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe on C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\System.Private.CoreLib.dll
1 errors compiling set.
Dasm command "jit-dasm-pmi --platform C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root --corerun C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe --jit C:\runtime\artifacts\bin\coreclr\Windows.x64.Checked\clrjit.dll --nocopy --output c:\diffs\dasmset_13\diff C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\System.Private.CoreLib.dll" returned with 1 failures
/ Finished 271/271 Base 270/271 Diff [562.0 sec]Error running C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe on C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\mscorlib.dll
1 errors compiling set.
Dasm command "jit-dasm-pmi --platform C:\runtime\artifacts\te| Finished 271/271 Base 270/271 Diff [562.1 sec]sts\coreclr\Windows.x64.Release\Tests\Core_Root --corerun C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe --jit C:\runtime\artifacts\bin\coreclr\Windows.x64.Checked\clrjit.dll --nocopy --output c:\diffs\dasmset_13\diff C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\mscorlib.dll" returned with 1 failures
\ Finished 271/271 Base 271/271 Diff [562.1 sec]
Dasm commands returned 2 base failures, 3 diff failures.
Completed PMI CodeSize Diffs for System.Private.CoreLib.dll, framework assemblies in 566.93s
This is the error message when running one of them, but I cannot relate it with my code change.
c:\JitBench\jitutils>C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\corerun.exe C:\runtime\artifacts\tests\coreclr\Windows.x64.Release\Tests\Core_Root\System.Private.CoreLib.dll
Unhandled exception. System.MissingMethodException: Entry point not found in assembly 'System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'.
Activity
EgorBo commentedon Oct 11, 2019
Interesting, 3 (and more) arguments in AreZero actually use this optimization:
Codegen:
(I suspect it happens in
Compiler::optOptimizeBools)EgorBo commentedon Oct 11, 2019
Hack:
where
BitConverter.IsLittleEndianis a runtimetrueconstant so Roslyn won't remove it.Codegen:
😄 sharplab.io
GrabYourPitchforks commentedon Oct 20, 2019
Similarly:
Current codegen:
Possible optimal codegen below, using the fact that the
orinstruction sets SF:JulieLeeMSFT commentedon Jan 13, 2021
Reproduced
AreZero(int x, int y)AreZero(int x, int y, int z), andAreZero(int x, int y)with the 3rd operand,BitConverter.IsLittleEndian.will check where the optimization happens.
JulieLeeMSFT commentedon Jan 26, 2021
Compiler::optOptimizeBoolsoptimizes toORonly if both the 1st basic block (BB) and the 2nd BB are conditional jump (BBJ_COND).Plan:
JulieLeeMSFT commentedon Feb 13, 2021
I was able to modify the code to generate the optimized code for the two argument case.
will run diffs and tests.
JulieLeeMSFT commentedon Feb 17, 2021
jit-diff shows 1440 methods improvement.
AndyAyersMS commentedon Feb 17, 2021
Unfortunately I think this may be telling you something has gone wrong -- for a change like this we would expect baseline and new jit to process the exact same number of methods.
Output like this means the new jit did not jit (or failed while trying to jit) some methods.
Was there a message printed before he output you show above about "reconciling"?
JulieLeeMSFT commentedon Feb 17, 2021
@AndyAyersMS you are right. There were 2 base and 3 diff error messages before this, and I was looking into it. Will ping you.
JulieLeeMSFT commentedon Feb 17, 2021
jit-diff error message
This is the error message when running one of them, but I cannot relate it with my code change.
JulieLeeMSFT commentedon Feb 20, 2021
Reproduced the issue. Debugging.
In
Compiler::optIsBoolCompthe tree gtType was incorrectly set toTYP_VOID."==0" optimization in Boolean logic #13573 (#49548)