Refactor float_to_float16_untyped_slow for clarity and optimization#330
Open
rfsaliev wants to merge 1 commit into
Open
Refactor float_to_float16_untyped_slow for clarity and optimization#330rfsaliev wants to merge 1 commit into
rfsaliev wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors svs::float16::detail::float_to_float16_untyped_slow (a float→FP16 conversion helper in the public header include/svs/lib/float16.h) from a single compound expression into explicit conditional branches for saturation, normalized, denormalized, and sign-only cases, while preserving the original thresholds and bit-manipulation behavior (including the bounded shift for denormal handling).
Changes:
- Replaces the prior “boolean-mask * value” expression with early-return branches for the same exponent ranges.
- Makes the denormal path’s shift amount explicit and constrained by control flow (avoiding out-of-range shifts for other exponent values).
ibhati
approved these changes
May 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the
float_to_float16_untyped_slowfunction infloat16.hto improve code clarity and maintainability. The logic is now expressed with clear conditional branches instead of a single complex expression, making it easier to understand and maintain while preserving the original functionality.Refactoring and code clarity:
float_to_float16_untyped_slowwith explicit conditional branches for handling saturation, normalization, denormalization, and sign extraction, improving readability and maintainability.float_to_float16_bench.cpp