Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

struct InRange: Add type that enforces its value is within a const generic range #1236

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

kkysen
Copy link
Collaborator

@kkysen kkysen commented Jun 20, 2024

Use it, for now, to optimize struct SegmentId (already similarly optimized, but not generically) and fn get_skip_ctx's return value.

Note that we need this for fn get_skip_ctx because it is not inlined, and thus the bounds checks using sctx aren't removed in fn decode_coefs. It is not inlined because fn get_skip_ctx is not BitDepth-generic, but fn decode_coefs is. I think dav1d still had fn get_skip_ctx inlined because it is manually duplicated with the templating system. But if LLVM thinks it is better not to inline this even with an #[inline] or even an #[inline(always)], and we're still able to propagate information through the return type, I'm inclined to leave it un-inlined.

@kkysen kkysen requested review from randomPoison and fbossen June 20, 2024 03:27
@kkysen kkysen force-pushed the kkysen/fn-get_skip_ctx-optimize branch from 170a19c to 92583a9 Compare June 20, 2024 05:40
@kkysen kkysen force-pushed the kkysen/struct-InRange branch from 0f9cf65 to 1b073ac Compare June 20, 2024 05:40
@kkysen kkysen force-pushed the kkysen/fn-get_skip_ctx-optimize branch from 92583a9 to 3fc67ba Compare June 21, 2024 21:13
@kkysen kkysen force-pushed the kkysen/struct-InRange branch from 1b073ac to ccb81ea Compare June 21, 2024 21:13
…generic range.

Use it, for now, to optimize `struct SegmentId` and `fn get_skip_ctx`'s return value.
@kkysen kkysen force-pushed the kkysen/fn-get_skip_ctx-optimize branch from 3fc67ba to 75be684 Compare June 23, 2024 23:58
@kkysen kkysen force-pushed the kkysen/struct-InRange branch from ccb81ea to f0a46a1 Compare June 23, 2024 23:58
Base automatically changed from kkysen/fn-get_skip_ctx-optimize to main June 24, 2024 00:49
@kkysen kkysen merged commit b3451b8 into main Jun 24, 2024
26 checks passed
@kkysen kkysen deleted the kkysen/struct-InRange branch June 24, 2024 00:49
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.

2 participants