← Back to Pull requests

[AMDGPU][GlobalISel] Select v_cvt_pk_bf16_f32 for bf16 fptrunc #242847

Open
unknown opened this pull request with 134 lines diff across 1 files
View on GitHub
unknown unknown commented on Nov 15, 2026 15:57 UTC
Author

On targets with bf16 conversion instructions (gfx950, gfx1250), GlobalISel always expanded f32 -> bf16 G_FPTRUNC into the integer rounding sequence (v_bfe/v_add3/NaN select/shift), while SelectionDAG selects v_cvt_pk_bf16_f32.

  • Make G_FPTRUNC {bf16, f32} and {<2 x bf16>, <2 x f32>} legal when hasBF16ConversionInsts(). f64 -> bf16 is still lowered (round-to-odd to f32), and its final step now also uses the native instruction.

  • Remove the bf16_fpround PatFrag, which existed only to disable these patterns for GlobalISel. Its FIXME (GlobalISel cannot distinguish f16 and bf16) no longer applies with extended LLTs.

  • Add a RegBankLegalize rule for uniform bf16 G_FPTRUNC. Without it, targets with SALU float (gfx1250) matched the uniform 16-bit SGPR rule and failed to select, since there is no scalar f32 -> bf16 conversion.
  • Restrict PackB32Pat to f16 elements in GlobalISel. Its v2f16 type check also accepted v2bf16, and v_pack_b32_f16 is not a plain bit move for bf16 values (this also affected bf16 log2/sqrt on gfx1250 fake16).
  • Diff: 134 lines (+100 / -34) across 1 files Reviewer: jayfoad Review duration: 23528m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.32) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.32 · 134 lines diff across 1 files
    0.32
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.293
    Real PR Conversation Timeline
    1 comments
    "Review active on #242847"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% 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: 32.3% (LOW) · Higher = larger blast radius
    32.3%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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.2% · Safe to merge
    17.2%