-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
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 SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Milestone
Description
In the code below, placing the comparison with Environment.NewLine inline after a non-runtime constant check produces extra code compared to hoisting the newline check to a local, or placing it first.
x86: https://godbolt.org/z/oeMWrEWje
arm: https://godbolt.org/z/EY3f8cscG
using System;
static class B
{
public static bool Hoisted(byte v)
{
bool isUnix = Environment.NewLine != "\r\n";
return (v == 2 && isUnix);
}
public static bool Inline_Before(byte v)
{
return (Environment.NewLine != "\r\n" && v == 2);
}
public static bool Inline_After(byte v)
{
return (v == 2 && Environment.NewLine != "\r\n");
}
}x86 example:
// expected
cmp dil, 2
sete al
movzx rax, al
ret
// actual
cmp dil, 2
je SHORT G_M4495_IG05
xor eax, eax
ret
G_M4495_IG05: ;; offset=0x0009
mov eax, 1
ret 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 SuperPMIhelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors