Type analysis through GEPs with a negative constant offset #3922
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 316 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.345
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #3922"
general
weight: 0.35
wsmoses
<!-- claude-projects-attribution: {"github_login":"vchuravy"} -->
_Requested by Valentin · project thread_
At
-O1and above, flang inlines array assignments, and Enzyme then failed with "Cannot deduce type of copy" on thememcpy/memmovethrough the temporary. Type analysis skipped GEPs with a negative offset, so the element types never reached the arrays. This affects allocatables and dummy arrays of unknown size. Found while looking at the flang-O1failures from #3913.flang addresses an element
x(i)of a 1-based array at&x[i - 1], which LLVM emits in one of two forms.After InstCombine:
After LICM hoists the step back (seen with flang 21):
Change
knownIntegralValues, as for a single GEP.-crelates its own bytes at offsets>= cto those of its base pointer.Testing
-
test/TypeAnalysis/gep_negative_offset_chain.ll(first form);-
test/TypeAnalysis/gep_negative_offset_hoisted.ll(second form);-
test/Fortran/ReverseMode/assignment_opt.f90, at-O1,-O2,-O3and through the flang plugin. Without this change it fails with "Cannot deduce type of copy" on flang 21. With it, the gradient is0 4 6 11, as derived by hand.config_file_lto.f90, which needs the LLD plugin my local build skipped and fails on main the same way.test/Enzyme,test/Integrationandtest/TypeAnalysisare the same as on main. They are typed-pointer tests that LLVM 21 cannot run. All Fortran tests pass.🤖 Generated with Claude Code