Skip to content

[Jit] Redundant comparisons are not eliminated #35348

@benaadams

Description

@benaadams

The following code

if (byteValue.Length >= (2 * sizeof(ulong) + sizeof(ushort)))
{
    if (BinaryPrimitives.ReadUInt64LittleEndian(byteValue) == keepChars)
    {

Generates a double comparison once against size 18; and a second against size 8 (which is already guaranteed by the size 18 check)

G_M33915_IG30:
       cmp      r10d, 18
       jl       G_M33915_IG36
       cmp      r10d, 8
       jl       G_M33915_IG59

Method is ParseConnection in this gist https://gist.github.com/benaadams/2ac588cc3dd65088db2bb51f9e4a89e1

Seen in dotnet/aspnetcore#21004

category:cq
theme:assertion-prop
skill-level:intermediate
cost:medium
impact:small

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIoptimization

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions