llvm / llvm/llvm-project

[KnownFPClass] Offer other types of dynamic Denormal Modes

Open
#221,841 2 comments 0 reactions 0 assignees View on GitHub
floating-point llvm:support
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Currently, `DenormalMode` can represent the following output/input denormal modes: `ieee`, `preservesign`, `positivezero`, and `dynamic`.

The `dynamic` mode assumes that all three denormal modes are possible. However, I would imagine that some hardware floating point units may only support two of the three denormal modes, (e.g. only `ieee` and `preservesign`), so we can make a few more deductions if the denormal mode is either `ieee` or `preservesign` but not `positivezero`.

One way we can represent things is with a bitmask, where `bit 0 = ieee`, `bit 1 = preservesign`, `bit 2 = positivezero`. All bits set would be the current `dynamic` mode, and a denormal mode that is either `ieee` or `preservesign` would be `0b011`. All bits cleared would refer to the current `invalid` state.

Another thing we could also add for the input denormal mode is `maybepreservesign` and `alwayspreservesign`, with the latter being a guarantee that input denormals always flush to zero.

Pros:
- Slightly stronger deductions with regards to output/input denormals.

Cons:
- More maintenance work, as the number of possible output/input modes goes from `4 * 4 = 16` to `7 * 7 = 49` (Assuming the output/input denormal mode cannot be `invalid`).

***

Also, currently, we would have to do a lot of work anyways if we were to add a new denormal mode (for example, one that flushes both subnormals and negative zero to positive zero).

Contributor guide

Open the contributing guide

Research direction

Start by locating the KnownFPClass handling of DenormalMode and reviewing how the current ieee, preservesign, positivezero, and dynamic states are represented. Resolve the proposed representation and input-mode additions before implementing them; done means the supported denormal combinations and resulting deductions are represented consistently.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.