Skip to content

subnormal_mode #243

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions AstSemantics.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,21 @@ nested. This guarantees that all resulting control flow graphs are well-structur
feature would allow efficient compilation of arbitrary irreducible control
flow.

## Floating Point Subnormal Handling

* `subnormal_mode`: Like [`block`](AstSemantics.md#control-flow-structures),
but with a mode attribute specifying special semantics for the handling of
subnormal values in all lexically contained [floating point operations][]
except `neg`, `abs`, and `copysign`, and [conversions][], except those in
contained `subnormal_mode` blocks. The mode may be one of:
* `standard`: standard semantics are followed
* `dont_care`: Subnormal values may or may not be interpreted as zero of the
same sign. Subnormal result values may or may not be replaced by any
subnormal value of the same sign, or zero of the same sign.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's "standard"? Wouldn't "IEEE754" be a better name?
I thought that we'd settled on "fastest" instead of "dont_care"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Standard" means the IEEE-754 standard, and also the WebAssembly standard, since it's the behavior we'll otherwise specify. Is there another standard which is remotely as authoritative in this regard?

In my opinion, "fastest" is implied. We always want the fastest performance permitted under the chosen semantics. "dont_care" makes it explicit that the programmer is choosing not to care about what happens, rather than blindly hoping that something named "fastest" will make their program faster without understanding what it means.


[floating point operations]: AstSemantics.md#floating-point-operations
[conversions]: AstSemantics.md#datatype-conversions-truncations-reinterpretations-promotions-and-demotions

## Calls

Direct calls to a function specify the callee by index into a function table.
Expand Down Expand Up @@ -400,8 +415,8 @@ Floating point arithmetic follows the IEEE-754 standard, except that:
- WebAssembly uses the round-to-nearest ties-to-even rounding attribute, except
where otherwise specified. Non-default directed rounding attributes are not
supported.
- The strategy for gradual underflow (subnormals) is
[under discussion](https://github.com/WebAssembly/design/issues/148).
- Inside the lexical extent of a `subnormal_mode` block, operators may follow
[alternate semantics](AstSemantics.md#floating-point-subnormal-handling).

In the future, these limitations may be lifted, enabling
[full IEEE-754 support](FutureFeatures.md#full-ieee-754-conformance).
Expand Down Expand Up @@ -485,8 +500,7 @@ Promotion and demotion of floating point values always succeed.
Demotion of floating point values uses round-to-nearest ties-to-even rounding,
and may overflow to infinity or negative infinity as specified by IEEE-754.
If the operand of promotion or demotion is NaN, the sign bit and significand
of the result are computed from an unspecified function of the implementation,
the opcode, and the operand.
of the result are not specified.

Reinterpretations always succeed.

Expand Down
16 changes: 10 additions & 6 deletions Nondeterminism.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ currently admits nondeterminism:
nondeterministic.
* Out of bounds heap accesses *may* want
[some flexibility](AstSemantics.md#out-of-bounds)
* [NaN bit patterns](AstSemantics.md#floating-point-operations)
* [Fixed-width SIMD may want some flexibility](PostMVP.md#fixed-width-simd)
- In SIMD.js, floating point values may or may not have subnormals flushed to
zero.
- In SIMD.js, operations ending in "Approximation" return approximations that
may vary between platforms.
* NaN bit patterns in floating point
[operations](AstSemantics.md#floating-point-operations) and
[conversions](AstSemantics.md#datatype-conversions-truncations-reinterpretations-promotions-and-demotions)
* Within the lexical extent of a
`dont_care` [`subnormal_mode`](AstSemantics.md#floating-point-subnormal-handling)
block, the interpretation and production of subnormal values is
nondeterministically relaxed.
* [Fixed-width SIMD](PostMVP.md#fixed-width-simd) may define operations with
names ending in "approximation" which return approximations that may vary
nondeterministically.
* Environment-dependent resource limits may be exhausted. A few examples:
- Memory allocation may fail.
- Program stack may get exhausted.
Expand Down