Skip to content

lifted comparison codegen can be improved #17261

@VSadov

Description

@VSadov

In the codegen of lifted comparison operators some conditional branches seem unnecessary.
They only serve to shortcircuit trivial bool operators over locals - that does not seem very profitable.

We should do something like in: dotnet/corefx#15941
( Also check dotnet/corefx#17535 if that is better )

Example:

We emit lifted equality for left and right as:

bool? result = (left.GetValueOrDefault() == right.GetValueOrDefault()) ?
                                                  ( left.HasValue == right.HasValue ) :
                                                   false;

A more efficient would be:

bool? result = (left.GetValueOrDefault() == right.GetValueOrDefault()) & 
                                           (left.HasValue == right.HasValue);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CompilersArea-PerformanceBugLanguage-C#good first issueThe issue is reserved for a first time, non-Microsoft contributorhelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions