[PATCH] D87877: [InstCombine] Fix errno bug in pow expansion to sqrt
Hubert Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 19:58:21 PDT 2020
hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: spatel, nemanjai, daltenty.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
hubert.reinterpretcast requested review of this revision.
A conversion from `pow` to `sqrt` shall not call an `errno`-setting `sqrt` with -infinity: the `sqrt` will set `EDOM` where the `pow` call would not.
This patch avoids the erroneous (pun not intended) transformation by applying the restrictions discussed in the thread for https://lists.llvm.org/pipermail/llvm-dev/2020-September/145051.html.
The existing tests are updated (depending on emphasis in the checks for
library calls, avoidance of overlap, and overall coverage):
- to add `ninf`, retaining the intended library call,
- to use the intrinsic, retaining the use of `select`, or
- to expect the replacement to not occur.
The following is tested:
- The pow intrinsic folds to a select instruction to handle -infinity.
- The pow library call folds, with `ninf`, to `sqrt` without the select instruction associated with handling -infinity.
- The pow library call does not fold to `sqrt` without `ninf`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D87877
Files:
llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/pow-1.ll
llvm/test/Transforms/InstCombine/pow-sqrt.ll
llvm/test/Transforms/InstCombine/win-math.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87877.292694.patch
Type: text/x-patch
Size: 16480 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200918/c40c7b60/attachment.bin>
More information about the llvm-commits
mailing list