llvm / llvm/llvm-project

[KnownFPClass] `roundToIntegral` does not account for input denormal mode

Open Beginner friendly
#217,412 0 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

Under `DAPZ` (denormals are positive zero) a negative subnormal input is interpreted as `+0.0`. So `trunc(negative_subnormal)` may produce positive zero.

In total, this impacts these functions:
- `trunc`
- `floor`
- `ceil`
- `round`
- `roundeven`
- `rint`
- `nearbyint`

Currently, `KnownFPClass::roundToIntegral` does not account for the input denormal mode and assumes that if the input is not a finite positive then the output will never be a finite positive. But under `DAPZ`, a negative subnormal could become positive zero, invalidating this deduction.

https://github.com/llvm/llvm-project/blob/9932f190f42e1a12c3cafea23938241abf6337ca/llvm/lib/Support/KnownFPClass.cpp#L766-L770

Contributor guide

Open the contributing guide

Research direction

Start in llvm/lib/Support/KnownFPClass.cpp at the roundToIntegral logic around lines 766-770. Trace how the input denormal mode is represented and how the result deduction affects trunc, floor, ceil, round, roundeven, rint, and nearbyint. Done means the DAPZ case, including a negative subnormal becoming positive zero, is accounted for without invalidating the other deductions.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.