← Back to Pull requests

AffineCFG: read a lowered division whose arms a canonicalize folded #3451

Closed
unknown closed this pull request without merging on Oct 10, 2026 00:45 UTC
View on GitHub
unknown unknown commented on Oct 09, 2026 22:16 UTC
Author

Split out of #3425. Merge this before #3425: the indicator #3425 writes into a loop bound contains a floordiv, which goes through lower-affine and back. Checked on MFEM: with #3425 alone, bilininteg_curlcurl_pa, bilininteg_mixedcurl_pa and test_curlcurl_integ fail to compile. With #3425 and this PR, all three compile.

The existing support for this is matchLoweredDiv (#3163). It reads lower-affine's expansion of floordiv/ceildiv/mod back for the normalizer, and keeps those selects away from MoveSelectToAffine (isLoweredDivSelect). But it matched the dividend arms as the expansion writes them: -1 - x for floordiv, 0 - x and x - 1 for ceildiv. The pipeline canonicalizes after lower-affine, and that folds those arms into x's own arithmetic. With x = 1 - c, -1 - x becomes c - 2. The selects then went unrecognized, MoveSelectToAffine split them into affine.ifs around a divsi, and the loop they bound stayed an scf loop with a non-affine bound.

This compares those arms to x as linear forms (isLinearIn, over addi/subi/multiplication by a constant), so the normalizer reads the division back whole. The earlier version of this PR added a separate pattern for the split affine.if form; that pattern is gone.

Test: affinecfg_lowered_div_folded.mlir takes the real lower-affine + canonicalize output for (1 - c) floordiv 2 + 3 and (1 - c) ceildiv 2 + 3. With --affine-cfg, both bounds come back as the division and the loops raise to affine.parallel. On main, both stay scf.for under split affine.ifs.

🤖 Generated with Claude Code

https://claude.ai/code/session_016zErYp7upmqr4NHfhod9UD

Diff: 213 lines (+159 / -54) across 2 files Reviewer: ImanHosseini Review duration: 148m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 213 lines diff across 2 files
0.37
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.321
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3451"
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: 36.6% (MEDIUM) · Higher = larger blast radius
36.6%
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: 14.4% · Safe to merge
14.4%