Track bool-returning and scalar-T-returning HW intrinsics via flags#128848
Merged
Conversation
Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add HWIntrinsicFlags for bool and scalar T tracking
Track bool-returning and scalar-T-returning HW intrinsics via flags
Jun 1, 2026
Member
|
CC. @EgorBo, the downside of this is that we were out of flag space and so it extends it up to I think there's likely cleanup possible and we can free up space, but I expect that's more involved and requires careful thought. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR centralizes knowledge about certain hardware intrinsics that return either a boolean (conceptually TYP_INT in range [0, 1]) or a scalar of the SIMD base type, by encoding that information as flags in the HW intrinsic table and switching consumers over to flag queries.
Changes:
- Widen
HWIntrinsicFlagtouint64_tand add common flags forReturnsBooleanandReturnsScalarT, exposed viaHWIntrinsicInfo. - Tag relevant xarch/arm64 intrinsic table entries with the new return-shape flags.
- Refactor
assertionprop.cpp,rangecheck.cpp, andvaluenum.cppto queryHWIntrinsicInfo::{ReturnsBoolean,ReturnsScalarT}instead of maintaining long intrinsic-ID switches.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/valuenum.cpp | Uses HW intrinsic return-shape flags to simplify IsVNNeverNegative handling for HWI VNs. |
| src/coreclr/jit/rangecheck.cpp | Uses HW intrinsic return-shape flags to derive ranges for HWI VNs without ID enumeration. |
| src/coreclr/jit/assertionprop.cpp | Uses HW intrinsic return-shape flags to derive symbolic integer ranges for GT_HWINTRINSIC. |
| src/coreclr/jit/hwintrinsiclistxarch.h | Tags xarch intrinsics (equality/test/compare, GetElement/ToScalar/Extract) with new return-shape flags. |
| src/coreclr/jit/hwintrinsiclistarm64.h | Tags arm64 intrinsics (equality, GetElement/ToScalar/Extract) with new return-shape flags. |
| src/coreclr/jit/hwintrinsic.h | Widens flag type and adds ReturnsBoolean / ReturnsScalarT APIs on HWIntrinsicInfo. |
3 tasks
EgorBo
reviewed
Jun 1, 2026
Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
EgorBo
reviewed
Jun 1, 2026
…heck Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
…unc blocks Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
EgorBo
approved these changes
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several hardware intrinsics are known to return
boolor a scalarT, but consumers (assertionprop, rangecheck, valuenum) tracked them via long ID switches that had to be kept in sync. Replace those with flags on the intrinsic table queryable throughHWIntrinsicInfo.hwintrinsic.hHWIntrinsicFlagtouint64_t(arm64 was out of bits in the 32-bit space).HW_Flag_ReturnsBooleanandHW_Flag_ReturnsScalarTas common flags.HWIntrinsicInfo::ReturnsBoolean/ReturnsScalarTstatic APIs, grouped afterReturnsPerElementMask.hwintrinsiclist*.hTag the entries previously enumerated in the consumer switches (skipping
HW_Flag_InvalidNodeIdentries per the issue):ReturnsBoolean(Vector{128,256,512}_op_{Equality,Inequality},X86Base.CompareScalar{Ordered,Unordered}*,X86Base/AVXTest{C,Z,NotZAndNotC}) and 8ReturnsScalarT(Vector{128,256,512}.{GetElement,ToScalar},X86Base[_X64].Extract).ReturnsBoolean(Vector{64,128}_op_{Equality,Inequality}) and 5ReturnsScalarT(Vector{64,128}.{GetElement,ToScalar},AdvSimd.Extract).Consumer refactors
assertionprop.cpp,rangecheck.cpp, andvaluenum.cppno longer enumerate intrinsic IDs in theirGT_HWINTRINSIC/VNF_HWI_*switches. A flag check runs before the remaining switch and preserves prior semantics, e.g.:For
IsVNNeverNegativethe scalar-T path keeps its base-type guard (onlyTYP_UBYTE/TYP_USHORTcontinue), matching the previous case-by-case behavior. The HW intrinsic checks inIsVNNeverNegativeandrangecheck.cppnow useIsVNHWIntrinsicFunc, eliminating the manualVNF_HWI_FIRST/VNF_HWI_LASTrange check, the explicitNamedIntrinsiccast, the separateGetVNHWIntrinsicSizeAndBaseTypecall. BothIsVNHWIntrinsicFuncblocks are correctly wrapped in#if defined(FEATURE_HW_INTRINSICS)/#endifguards.SVE bool/scalar-T intrinsics are intentionally not tagged here — they were never in the original switches and remain covered by the existing
TODO-SVEnotes.