Skip to content

Vector.IsHardwareAccelerated result differs when called directly and called via reflection #38162

Closed
@AndyAyersMS

Description

@AndyAyersMS
using System;
using System.Reflection;
using System.Numerics;

class X
{
    public static int Main()
    {
        bool hw1 = Vector.IsHardwareAccelerated;

        Assembly spc = typeof(object).Assembly;
        Type vecType = spc.GetType("System.Numerics.Vector");
        MethodInfo method = vecType.GetMethod("get_IsHardwareAccelerated");
        bool hw2 = (bool) method.Invoke(null, null);

        Console.WriteLine($"Direct call to Vector.IsHardwareAccelerated returns {hw1}");
        Console.WriteLine($"Reflection call to Vector.IsHardwareAccelerated returns {hw2}");

        return (hw1 == hw2 ? 100 : -1);
    }
}

results in

Direct call to Vector.IsHardwareAccelerated returns True
Reflection call to Vector.IsHardwareAccelerated returns False

Seems like we're not recognizing this as an intrinsic when it is jitted on its own.

category:cq
theme:vector-codegen
skill-level:intermediate
cost:medium

Metadata

Metadata

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions