[PATCH] D50900: [SimplifyLibCalls] Support pow(x, -0.5) in replacePowWithSqrt without NSZ/noInfs.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 17 07:37:10 PDT 2018


fhahn created this revision.
fhahn added reviewers: efriedma, evandro, paulwalker-arm, spatel, wmi.

This patch enables the following expansion in replacePowWithSqrt:

  pow(x, -0.5) to (x == -infinity ? +0.0 : fabs(1/sqrt(x)))

I am not entirely sure about handling x == +-0.0, as it seems like different
implementations treat it differently. E.g. on Linux

  If x is +0 or -0, and y is less than 0 and not an odd integer, a pole error
  occurs and +HUGE_VAL, +HUGE_VALF, or +HUGE_VALL, is returned.

On MacOS

  pow(+-0, y) returns +infinity and raises the "divide-by-zero" floating-point
  exception for y < 0 and not an odd integer.

So on MacOS we should do the right thing and return +infinity for both
+0 and -0, but on Linux we should actually return +HUGE_VAL.


https://reviews.llvm.org/D50900

Files:
  lib/Transforms/Utils/SimplifyLibCalls.cpp
  test/Transforms/InstCombine/pow-sqrt.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50900.161244.patch
Type: text/x-patch
Size: 7121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180817/6574c97f/attachment.bin>


More information about the llvm-commits mailing list