Skip to content

Conversation

@cdleary
Copy link
Collaborator

@cdleary cdleary commented Jan 10, 2026

Takes a whack at range analysis for the encode IR op.

Fast exact case (small input range): If the input’s IntervalSet contains only a small number of concrete values (<= kMaxIterationSize), we enumerate each possible input value, compute encode result exactly, and union the results. This produces an exact output set and is still cheap because the input set is small by construction.

Fallback (large input range): If the input range is large, we avoid enumerating it. Instead, we extract a ternary mask for the input bits (known-0 / known-1 / unknown) from the input interval set, and compute each output bit using the encode op definition ("output bit j is the OR of input bits whose index has bit j set"). If any input bit is known-1 the output bit is known-1; if none are known-1 but at least one is unknown the output bit is unknown, otherwise it’s known-0. We convert that output ternary mask into an IntervalSet (interval_ops::FromTernary), which is conservative but fast.

Fuzzed multiprocess for >15 mins on a many-core machine.

@cdleary cdleary marked this pull request as ready for review January 10, 2026 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants