Skip to content

Conversation

@niaow
Copy link
Member

@niaow niaow commented Dec 28, 2025

This fixes two edge cases for min/max:
min/max(+0.0, -0.0) = -0.0, +0.0
min/max(number, NaN) = NaN, NaN

The compare and select method does not work here.
I switched to the llvm.minimum/llvm.maximum intrinsics which match the intended behavior.

The integer min/max were also swapped over to using intrinsics. The compare and select path is now only used by strings.

This fixes two edge cases for min/max:
min/max(+0.0, -0.0) = -0.0, +0.0
min/max(number, NaN) = NaN, NaN

The compare and select method does not work here.
I switched to the llvm.minimum/llvm.maximum intrinsics which match the intended behavior.

The integer min/max were also swapped over to using intrinsics.
The compare and select path is now only used by strings.
@eliasnaur
Copy link
Contributor

Is there a Big Go test that can now be enabled? Otherwise, I'm surprised these edge cases are not covered.

@niaow
Copy link
Member Author

niaow commented Dec 28, 2025

Not as far as I know. I just added the cases to testdata.

@niaow niaow added the core label Jan 1, 2026
@niaow niaow requested a review from dgryski January 2, 2026 08:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants