Skip to content

JIT: type assertion prop doesn't know declared types for args or locals #9057

Open

Description

@AndyAyersMS

This limits the ability to reason about subtypes. For instance in the following example the jit cannot optimize away the cast:

using System;
using System.Collections.Generic;

class Program
{
    static void Main() => MyMethod(new char[0]);

    static void MyMethod<T>(IEnumerable<T> chars)
    {
        if (typeof(T) == typeof(char))
        {
            foreach (char c in (IEnumerable<char>)chars) { }
        }
    }
}

One idea here is to allow assertion prop to fall back to querying known sources of type information, eg gtGetClassHandle, when assertions are lacking. One might also consider teaching assertion prop that sealed classes are particularly interesting.

Likely however, most interesting cases of this kind can be caught earlier and with better effect (since this may unblock devirt/inlining or streamline importation), so it may not be worth doing anything here, once the anticipated cast optimizations in the importer are implemented.

category:cq
theme:assertion-prop
skill-level:expert
cost:medium

Activity

  1. transferred this issue fromdotnet/coreclron Jan 31, 2020
  2. added this to the Future milestone on Jan 31, 2020
  3. added
    JitUntriaged
    on Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    JitUntriagedarea-CodeGen-coreclrenhancementoptimizationtenet-performance

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions