Derivatives of the LLVM flang runtime MOD and MODULO for reals #3878
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 174 lines diff across 2 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.309
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #3878"
general
weight: 0.35
vchuravy
<!-- claude-projects-attribution: {"github_login":"vchuravy"} -->
_Requested by Valentin · project thread_
LLVM flang emits
MODandMODULOofREAL(4),REAL(8)andREAL(10)as calls into its runtime,_FortranAModReal<k>(a, p, sourceFile, sourceLine)and_FortranAModuloReal<k>(...). Enzyme had no derivative for them, so reverse mode failed withNo reverse pass found for _FortranAModReal8.This adds
CallPatterns for them inInstructionDerivatives.td, next tofmod:MOD(a, p) = a - aint(a/p) p: d/da = 1, d/dp = -trunc(a/p).MODULO(a, p) = a - floor(a/p) p: d/da = 1, d/dp = -floor(a/p).The primal call stays as it is, so results match flang's runtime exactly.
REAL(16)is left out, as it is in flang's inline lowering.Supersedes #3363, which replaced the calls with
freminpreserve-nvvm.Tests:
ReverseMode/flang-mod-real.ll(MOD and MODULO of REAL(8)) andForwardMode/flang-mod-real.ll(MOD of REAL(4)). Both pass locally against LLVM df0a91f6, as does the existingReverseMode/fmod.ll. Found while differentiating MITgcm'sEXTERNAL_FIELDS_LOADwith flang and full LTO.---
_Generated by Claude Code_