Skip to content

Add compact strided TypeTree ranges for large arrays - #33

Closed
Dnreikronos wants to merge 1 commit into
rust-lang:mainfrom
Dnreikronos:typetree-strided-ranges
Closed

Add compact strided TypeTree ranges for large arrays#33
Dnreikronos wants to merge 1 commit into
rust-lang:mainfrom
Dnreikronos:typetree-strided-ranges

Conversation

@Dnreikronos

Copy link
Copy Markdown

Summary

Dense per-element TypeTree offsets are impractical for large inline arrays and are dropped above Enzyme's MaxTypeOffset (default 500). Mixed aggregates such as { i64, [f32; 1000] } therefore could not describe the final array element, and a whole-region [-1]:Float is wrong when a sibling field has another base type.

This adds compact strided ranges:

  • Wire form: {[-1,8+4*1000]:Float@float} meaning floats at 8 + 4*k for k in 0..1000
  • First-class StridedTypeRange storage (no per-element map keys)
  • EnzymeTypeTreeInsertRangeEq C API for frontends
  • parse/str/operator[]/Only/Data0/orIn/ShiftIndices support
  • Lit test TypeAnalysis/stridedrange.ll

Needed by rust-lang/rust#160701 so rustc can emit bounded inline-array metadata.

Test plan

  • enzyme/test/TypeAnalysis/stridedrange.ll
  • Enzyme TypeAnalysis lit suite

Made with Cursor

Dense per-element offsets waste memory and are dropped above
MaxTypeOffset (default 500), so mixed aggregates like
`{ i64, [f32; 1000] }` could not describe the final array element.

Introduce `start+stride*count` index syntax and first-class
StridedTypeRange storage so frontends can emit compact homogeneous
array regions that remain queryable past the offset cap.
@Dnreikronos
Dnreikronos force-pushed the typetree-strided-ranges branch from eaa0656 to 5ce0a59 Compare August 11, 2026 16:21
@Dnreikronos
Dnreikronos deleted the typetree-strided-ranges branch August 11, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant