Skip to content

Conversation

@anthonycanino
Copy link
Contributor

This PR adjust GenTreeJitIntrinsic to save the base type of SIMD operation as a var_types and not CorInfoType. This is done to allow SIMD operations on types that are not part of the CIL.

Some notes on the changes:

  1. simdBaseJitType has been renamed to simdBaseType and most flows that previous had both a simdBaseJitType and simdBaseType now only use the simdBaseType.
  2. simdBaseType should now refer to the type returned via JitType2PreciseVarType.
  3. Some instances required the less precise, JitType2VarType.
  4. gtAuxiliaryJitType has been left unchanged. Some new functions have been introduced called getCorBaseTypeXX that keep the original behavior.

If we decide to also change gtAuxiliaryJitType I can make the changes and refactor things a bit more.

Current opening PR as draft to get a test run.

@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 31, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 31, 2025
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@anthonycanino anthonycanino marked this pull request as ready for review November 4, 2025 21:33
Copilot AI review requested due to automatic review settings November 4, 2025 21:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors GenTreeJitIntrinsic to store the base type for SIMD operations as var_types instead of CorInfoType, enabling support for SIMD operations on types not part of the CIL. The changes include:

  • Renaming simdBaseJitType to simdBaseType throughout the codebase
  • Converting CorInfoType parameters to var_types in SIMD-related functions
  • Introducing new helper functions like getBaseTypeForPrimitiveNumericClass and getBaseTypeAndSizeOfSIMDType
  • Maintaining backward compatibility through new getCorBaseTypeXX functions

Reviewed Changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated no comments.

Show a summary per file
File Description
valuenum.h Updated signature of VNForSimdType to use var_types instead of CorInfoType
valuenum.cpp Changed parameter types in VNForSimdType and updated call sites
simd.cpp Added new getBaseTypeAndSizeOfSIMDType function returning var_types, refactored from original implementation
rationalize.cpp Updated all SIMD intrinsic operations to use var_types for base type tracking
optimizemaskconversions.cpp Changed mask conversion tracking to use var_types
morph.cpp Updated HWIntrinsic morphing to use var_types throughout
lowerxarch.cpp Converted all SIMD lowering operations to use var_types
lowerarmarch.cpp Updated ARM-specific SIMD lowering to use var_types
lower.h Changed function signature for InsertNewSimdCreateScalarUnsafeNode
lower.cpp Updated implementation to use var_types
lclvars.cpp Changed local variable promotion to use var_types
lclmorph.cpp Updated local morphing to use var_types
importervectorization.cpp Changed vectorization import to use var_types
importercalls.cpp Updated intrinsic call handling to use var_types with JitType2PreciseVarType conversions
importer.cpp Changed impNormStructType signature and implementation
hwintrinsicxarch.cpp Updated x86/x64 intrinsic handling with extensive conversions from CorInfoType to var_types
hwintrinsiccodegenxarch.cpp Updated codegen to use var_types
hwintrinsicarm64.cpp Converted ARM64 intrinsic handling to use var_types throughout


if (simdBaseJitType == CORINFO_TYPE_UNDEF)
var_types GenTreeJitIntrinsic::GetSimdBaseTypeAsVarType() const
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This name is a bit confusing.

I also thought we had something which covered this normalization already. genActualType isn't quite it, since it does smallTypes -> TYP_INT as well, but I was thinking we already had a helper for return varTypeIsSmall(x) ? x : genActualType(x);

Perhaps @EgorBo or @jakobbotsch remember?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on how this is used, genActualType itself might be the "better" choice.

Copy link
Member

@jakobbotsch jakobbotsch Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this is confusing. What is this used for?

If this is used to get the type to use for loads or stores of elements then perhaps something like GetIndirTypeForElement? (It should have comment about it as well.)

Perhaps @EgorBo or @jakobbotsch remember?

I don't think we have anything that does this exact operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is used in places where the jit wants the base type for canonicalization purposes (TYP_INT or TYP_LONG) and does not want to differentiate between TYP_INT and TYP_UINT etc.

This was for places where JitType2VarType was used and not JitType2PreciseVarType.

@tannergooding
Copy link
Member

cc. @dotnet/jit-contrib, @EgorBo, @jakobbotsch for secondary review

@jakobbotsch jakobbotsch self-requested a review November 6, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants