Uh oh!
There was an error while loading. Please reload this page.
Track bool-returning and scalar-T-returning HW intrinsics via flags - #128848
Conversation
Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
tannergooding
commented
Jun 1, 2026
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. |
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. |
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
…heck Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…unc blocks Co-authored-by: tannergooding <10487869+tannergooding@users.noreply.github.com>
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.