stage2: lower float negation explicitly + modify hash/eql logic for floats #11967
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.
Rather than lowering float negation as
0.0 - x
, this commit makes Zig lower it with a negation AIR instruction. It also adds compiler-rt functions for f128 and f80 negation.This revealed a problem with the way generic functions work for floats:
Zig guarantees the memory layout of f16, f32, f64, f80, and f128 which
means for generic function purposes, values of these types need to be
compared on the basis of their bits in memory. This means nan-packing
can be used with generic functions, for example.
For comptime_float, the sign is observable, whether it is nan is
observable, but not any more kinds of bit patterns are observable.
This fixes the std.fmt tests that check printing "-nan".
closes #11853