`[InstCombine]` Fold `exp(subnormal)` and `exp(+inf)` to `x + 1.0`
https://github.com/llvm/llvm-project/blob/f1b92cc3a1b0d13b01633b1d333a033b2da8006a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp#L3194-L3203
Currently, we perform these folds:
exp(zero)-->1.0exp(zero | NaN)-->x + 1.0exp(+-inf | NaN)-->select (fcmp ueq x, +inf) x, +0.0
Since exp(x) = 1.0 + x + ..., and 1.0 + subnormal == 1.0, we can also fold exp(subnormal) --> 1.0. Also exp(+inf) == +inf.
TODO:
- Fold
exp(zero | subnormal)-->1.0(Invalid forRoundingMode::Dynamic, although we don't have to worry about this here). - Fold
exp(zero | subnormal | +inf | NaN)-->x + 1.0 - Also make sure we do not fold
exp(zero | subnormal | +-inf | NaN)-->x + 1.0
These also apply to exp2 and exp10.
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
- Check that no other contributor is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
- Leave a comment indicating that you are working on the issue, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
- Fix the issue locally. Be aware that LLVM's AI policy forbids the use of AI tools to fix good first issues since it squanders a learning opportunity. Using LLMs to search and learn is permitted, since the goal is learning.
- Run the test suite locally. Remember that the subdirectories under
test/create fine-grained testing targets, so you can e.g. usemake check-clang-astto only run Clang's AST tests. - Create a Git commit.
- Run
git clang-format HEAD~1to format your changes. - Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: Eric Ross (ZERICO2005)
Currently, we perform these folds:
exp(zero)-->1.0exp(zero | NaN)-->x + 1.0exp(+-inf | NaN)-->select (fcmp ueq x, +inf) x, +0.0
Since exp(x) = 1.0 + x + ..., and 1.0 + subnormal == 1.0, we can also fold exp(subnormal) --> 1.0. Also exp(+inf) == +inf.
TODO:
- Fold
exp(zero | subnormal)-->1.0(Invalid forRoundingMode::Dynamic, although we don't have to worry about this here). - Fold
exp(zero | subnormal | +inf | NaN)-->x + 1.0 - Also make sure we do not fold
exp(zero | subnormal | +-inf | NaN)-->x + 1.0
These also apply to exp2 and exp10.
can i work on this issue
@ujwal-224 if you are working on another issue I can work on it
Can I work on this issue?
@0xPaarth I have already assigned this issue to @ujwal-224, you can ask if they are still working on the issue in one week.