Handle signed zero and non-finite f32 constants - #628
Merged
Conversation
The interpreter's IEEE-754 division fallback selected infinity from the numerator sign alone, so division by negative zero returned the wrong sign. Combine both operand signs with copysign while retaining NaN for zero divided by zero. Redshift can fold f32 overflow into infinity. The C writer previously appended an f suffix to Python's spelling and emitted invalid identifiers such as inff and nanf; emit the C99 INFINITY and NAN macros instead. The signed-zero regression constructs -0.0 inside SPy, so it tests signed-zero behavior independently of Python-to-SPy argument conversion. The constant-emission regression overflows the largest finite f32 deliberately, ensuring the C writer receives a folded non-finite constant instead of a runtime division call.
antocuni
approved these changes
Jul 19, 2026
antocuni
left a comment
Member
There was a problem hiding this comment.
LGTM. Will merge as soon as tests turn green
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.
The interpreter's IEEE-754 division fallback selected infinity from the numerator sign alone, so division by negative zero returned the wrong sign. Combine both operand signs with copysign while retaining NaN for zero divided by zero.
Redshift can fold
f32overflow into infinity. The C writer previously appended anfsuffix to Python's spelling and emitted invalid identifiers such asinffandnanf; emit the C99INFINITYandNANmacros instead.The signed-zero regression constructs -0.0 inside SPy, so it tests signed-zero behavior independently of Python-to-SPy argument conversion. The constant-emission regression overflows the largest finite
f32deliberately, ensuring the C writer receives a folded non-finite constant instead of a runtime division call.It was possible thanks to the help of gpt-5.6-sol.