llvm / llvm/llvm-project

[KnownFPClass] Add sNaN deductions for `sin`, `cos`, and `tan`

Open
#217,150 3 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

`KnownFPClass::sin`, `KnownFPClass::cos`, and `KnownFPClass::tan` can currently rule out `NaN` when the input is known to be non-`NaN` and finite, but they do not separately propagate knowledge that the input cannot be `sNaN`.

`sin`, `cos`, and `tan` can only return `sNaN` if the input is `sNaN`. For an `sNaN` input, the result may non-deterministically be either `qNaN` or `sNaN`. Therefore, if the input is known not to be `sNaN`, the result can also be known not to be `sNaN`.

The `KnownFPClass::propagateNonSNaN()` helper can be used to perform this deduction.

Tests should be added/updated for the `sin`, `cos`, and `tan` deductions, including cases where the source is known not to be an `sNaN`.

Contributor guide

Open the contributing guide

Research direction

Start by locating the KnownFPClass::sin, KnownFPClass::cos, and KnownFPClass::tan implementations and their existing tests. Read how propagateNonSNaN() is used, then add or update tests covering inputs known not to be sNaN and verify that all three deductions establish the corresponding result property.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.