[PATCH] D49040: [SLC] Simplify pow(x, 0.333...) to cbrt(x)

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 9 12:20:08 PDT 2018


efriedma added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp:1125
+  // Only in finite and normal math.
+  if (!Pow->hasNoInfs() || !Pow->hasNoNaNs())
+    return nullptr;
----------------
efriedma wrote:
> You need nsz: `pow(-0., 1./3)` returns +0, but `cbrt(-0.)` returns -0.
> 
> I think I'd prefer to require afn for this; not sure it's necessary, but better to be safe.
> 
> Please add explicit comments explaining why you need nnan and ninf (nnan because pow() returns a nan for negative x, ninf for `pow(-inf, 1./3)`).
isFast() is deprecated, because it makes the actual requirements unclear and disables optimizations where it isn't necessary.  (In particular, you don't need reassoc here.)


https://reviews.llvm.org/D49040





More information about the llvm-commits mailing list