Skip to content

optimized fneg#771

Open
ZERICO2005 wants to merge 1 commit intomasterfrom
opt_fneg
Open

optimized fneg#771
ZERICO2005 wants to merge 1 commit intomasterfrom
opt_fneg

Conversation

@ZERICO2005
Copy link
Copy Markdown
Contributor

@ZERICO2005 ZERICO2005 commented Mar 30, 2026

I have optimized fneg, making the common case 3F faster. The main decision left is for inputs [+0.0f, +FLT_MIN * 2.0f), since we can make the case of input == 0.0f slightly faster (-1F + 1) at the cost of [+FLT_TRUE_MIN, +FLT_MIN * 2.0f) being slightly slower (+1F + 1)

Previous code:

    ; 13 bytes
    ; A != 0        :  8F + 3R + 0W + 2
    ; A:UBC == 0.0f : 11F + 6R + 3W + 2
    ; A:UBC != 0.0f : 14F + 6R + 3W + 2

Option 1 (optimize equally):

    ; 12 bytes
    ; A != 0        :  5F + 3R + 0W + 2
    ; A:UBC == 0.0f : 13F + 6R + 3W + 3
    ; A:UBC != 0.0f : 13F + 6R + 3W + 3

Option 2 (optimize input == 0.0f):

    ; 13 bytes
    ; A != 0        :  5F + 3R + 0W + 2
    ; A:UBC == 0.0f : 12F + 6R + 3W + 3
    ; A:UBC != 0.0f : 14F + 6R + 3W + 3

@ZERICO2005 ZERICO2005 marked this pull request as ready for review April 1, 2026 18:12
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