Divide without normalization when the quotient is a single word #377
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 375 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.355
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #377"
general
weight: 0.35
chfast
When the numerator and the divisor have the same size and the top word of the divisor is not zero, the quotient fits in a single word. Estimate it by dividing the top 2 words of the normalized numerator by the top word of the normalized divisor (2/1 division, at most 2 too large) and compute the remainder with
submul()on the original operands, correcting the quotient 0–2 times. This skips normalizing the whole operands and the Knuth division. This is the "small quotient" case of GMP'smpn_tdiv_qr().num_words - 1divisor words, so it is not instantiated forudivrem<192, 192>(extends #381).Earlier revisions had a GCC
fshr()workaround (superseded by #379) and anINTX_ASSUMEbound on the Knuth divisor word count (dropped: no effect with clang, mixed results with GCC).Instructions per operation
Average dynamic instruction counts per call, 64K random inputs, clang 23 and GCC 16 at
-O2,-O3and-O2 -march=x86-64-v3, compared with main after #382:| case | clang | GCC |
|---|---|---|
| uint256 / full-width divisor | −40 … −160 | −55 … −176 |
| uint512 / full-width divisor | −49 … −227 | −76 … −324 |
| uint192 / full-width divisor | −27 … −155 | −48 … −135 |
| uint256 / 3-word divisor | +2 | −13 … −17 |
|
to_string()uint256 | −20 … −145 | +11 … +270 |Other sizes (
mulmod,addmod, 512/256, 320/256) are not affected.Regressions:
-O3, uint192 with a 2-word divisor: +1 … +2.to_string(): +11 … +270 (most at-O2and-march=x86-64-v3). GCC inlinesudivrem_top1()intoudivrem()and the larger function costs a few instructions on the other paths: withudivrem_top1()not inlined most of this goes away.udivrem_by2()intoudivrem<192, 192>anymore.-O3, uint512 with 1- to 6-word divisors: +1 … +3.5.Together with #382, compared with main,
to_string()is −50 … −348 instructions with clang and −29 … −726 with GCC.Code size
clang:
udivrem()instantiations are the same size or smaller (udivrem<192, 192>204 → 137 instructions); clang callsudivrem_top1()out of line. GCC: +100 … +165 instructions perudivrem()instantiation because it inlinesudivrem_top1()with itssubmul()andadd()loops. GCC no longer emits the out-of-lineudivrem_knuth()(1081 bytes at-O2) for code dividing onlyuint<192>byuint<192>.Coverage
The changed lines have 100% coverage with clang
-fcoverage-mcdcand GCC-fcondition-coverage.🤖 Generated with Claude Code
https://claude.ai/code/session_01LYMd9JA9ad8WxPeZGwwzcS