Simpler nullcheck can be emitted
Open
area-CodeGen-coreclr
- Dominant language
- C#
- Stars
- 18.3k
- Forks
- 5.6k
- PR merge metrics
- PR metrics pending
Description
Another finding from https://github.com/dotnet/runtime/pull/123290 diffs
```cs
private readonly char _oldValue;
private readonly char _newValue;
public void Test()
{
ReadOnlySpan.Empty.Replace(Span.Empty, _oldValue, _newValue);
}
```
Actual codegen:
```asm
; Method Runtime_122254:Test():this (FullOpts)
movsx rax, word ptr [rcx+0x08]
ret
; Total bytes of code: 6
```
Expected codegen:
```asm
; Method Runtime_122254:Test():this (FullOpts)
cmp byte ptr [rcx+0x08], cl
ret
```
unused `IND(ADD(X, CNS))` should be converted into `NULLCHECK`
Contributor guide
Assessment
This issue has not been assessed yet.