Skip to content

Optimize Enum.GetUnderlyingType with a known type to a constant #70483

Closed
@MichalPetryka

Description

@MichalPetryka

Description

Enum.GetUnderlyingType currently always does a runtime lookup even when the type is always known, for example due to being a generic parameter. This makes fast generic specialization on enums impossible, unless you specialize on their size, which in turn makes you loose information about the sign.
Having this optimized would make #70167 much more useful since currently you have no fast way to check if the conversion is safe.

Configuration

Core CLR 6.0.322.12309 on amd64 on SharpLab

Regression?

I don't think so, but haven't checked other runtimes.

Data

SharpLab

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIin-prThere is an active PR which will close this issue when it is mergedtenet-performancePerformance related issue

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions