← Back to Pull requests

Fix equal-magnitude MIN_ABS/MAX_ABS selection in VRANGE instructions #855

Closed
unknown closed this pull request without merging on Aug 30, 2026 04:41 UTC
View on GitHub
unknown unknown commented on Aug 29, 2026 17:31 UTC
Author

Problem

The shared f32_range and f64_range helpers implement the MIN_ABS and
MAX_ABS operations used by VRANGEPD, VRANGEPS, VRANGESD, and
VRANGESS.

For absolute-value comparisons, the helpers clear both operand signs and use
a strict less-than comparison. When the operands have equal magnitudes but
opposite signs, equality therefore falls through to a source-order-dependent
choice: MIN_ABS selects SRC2 and MAX_ABS selects SRC1.

Consequently, one source order returns the positive operand for MIN_ABS and
the negative operand for MAX_ABS. This also affects -0.0/+0.0 ties.

Fix

Extend the existing opposite-sign selection path to cover equal-magnitude
absolute comparisons. The helpers compare magnitudes by clearing the IEEE-754
sign bit from each operand before testing for equality.

This follows the existing Bochs SoftFloat convention used by the float32,
float64, and float16 MINMAX helpers, as well as by the surrounding RANGE
code.

When the magnitudes are equal and the signs differ, the existing selection
logic then chooses the negative operand for MIN_ABS and the positive operand
for MAX_ABS, independent of source order. NaN handling and DAZ normalization
remain unchanged and occur before this selection.

Architectural reference

The Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2,
sections “VRANGEPD—Range Restriction Calculation for Packed Pairs of Float64
Values,” “VRANGEPS—Range Restriction Calculation for Packed Pairs of Float32
Values,” “VRANGESD—Range Restriction Calculation From a Pair of Scalar
Float64 Values,” and “VRANGESS—Range Restriction Calculation From a Pair of
Scalar Float32 Values,” define the range operations in Tables 5-22 and 5-23.

For equal-magnitude operands with opposite signs, those tables require
MIN_ABS to select the negative operand and MAX_ABS to select the positive
operand.

  • Intel® Software Developer Manuals download page
  • Validation

    A standalone 64-bit CPL3 guest exercised the four instructions on the Bochs
    tigerlake CPU model with AVX-512 state enabled (XCR0=0xe7). The tie tests
    used both source orders for -1.0/+1.0 and -0.0/+0.0, with sign control
    set to preserve the selected operand’s sign.

    | Instruction | Operations and tie inputs | Before | After |
    |---|---|---:|---:|
    | VRANGEPD | MIN_ABS/MAX_ABS, ±1.0 and ±0.0, both orders | FAIL | PASS |
    | VRANGEPS | MIN_ABS/MAX_ABS, ±1.0 and ±0.0, both orders | FAIL | PASS |
    | VRANGESD | MIN_ABS/MAX_ABS, ±1.0 and ±0.0, both orders | FAIL | PASS |
    | VRANGESS | MIN_ABS/MAX_ABS, ±1.0 and ±0.0, both orders | FAIL | PASS |

    Additional controls passed after the change:

  • unequal-magnitude MIN_ABS and MAX_ABS inputs;

  • immediate 0x02 source-1 sign control;

  • packed merge masking;

  • scalar active, merge-masked, and zero-masked forms;

  • scalar upper-element preservation and ZMM upper-bit clearing; and

  • quiet NaN, signaling NaN, DAZ, denormal-input, and exception-flag helper

  • checks for both float32 and float64.

    The patched tree was rebuilt successfully with make -j2.

    Diff: 410 lines (+307 / -103) across 5 files Reviewer: stlintel Review duration: 669m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 410 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.360
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #855"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.9% (MEDIUM) · Higher = larger blast radius
    44.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.7% · Safe to merge
    17.7%