-
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 SuperPMI
Milestone
Description
public static int Foo(string str)
{
int length = str.Length;
while ((uint)(length - 1) < (uint)str.Length && str[length - 1] == ' ')
{
length--;
}
return length;
}
public static int Bar(string str)
{
int length = str.Length;
while (length > 0 && str[length - 1] == ' ')
{
length--;
}
return length;
}In .NET 9, Foo elided the extra bounds check, but godbolt is showing it again on main https://godbolt.org/z/qnYEzcdne.
Bar also seems like something where the JIT could prove that an extra check isn't needed.
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 SuperPMI