[InstCombine] Remove hasNoInfs check for pow(C,y) -> exp2(log2(C)*y)
authorJay Foad <jay.foad@amd.com>
Tue, 5 May 2020 12:00:48 +0000 (13:00 +0100)
committerJay Foad <jay.foad@amd.com>
Tue, 19 May 2020 16:06:05 +0000 (17:06 +0100)
commit9bc989a48d639d04283d6144505e33e8e354c783
tree0376be152982a4994bbfb927316541dcee5da656
parent64676499741cb985146ab982a67da859ff8f4f4d
[InstCombine] Remove hasNoInfs check for pow(C,y) -> exp2(log2(C)*y)

We already check hasNoNaNs and that x is finite and strictly positive.
That only leaves the following special cases (taken from the Linux man
page for pow):

If x is +1, the result is 1.0 (even if y is a NaN).
If the absolute value of x is less than 1, and y is negative infinity, the result is positive infinity.
If the absolute value of x is greater than 1, and y is negative infinity, the result is +0.
If the absolute value of x is less than 1, and y is positive infinity, the result is +0.
If the absolute value of x is greater than 1, and y is positive infinity, the result is positive infinity.

The first case is handled elsewhere, and this transformation preserves
all the others, so there is no need to limit it to hasNoInfs.

Differential Revision: https://reviews.llvm.org/D79409
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/pow-exp.ll