Skip to content

Fixed float to integer punning in nanoprintf.c #590

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ZERICO2005
Copy link
Contributor

@ZERICO2005 ZERICO2005 commented Apr 16, 2025

union-cast is UB, let compiler optimize byte-copy loop.

The compiler wasn't able to see through the byte-copy loop so it generated inefficient code.
I have fixed this by using a memcpy to perform the float to integer punning. This reduced the required stack frame from 140 to 108 bytes, which allows the code to be within the +-127 byte range of IX

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant