[PATCH] D51435: [SLC] Support expanding pow(x, n+0.5) to x * x * ... * sqrt(x)

Evandro Menezes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 29 12:54:09 PDT 2018


evandro added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1362
+        APFloat VInt = ExpoA;
+        if (VInt.add(ExpoA, APFloat::rmNearestTiesToEven) != APFloat::opOK)
+          return nullptr;
----------------
May I suggest `s/VInt/Expo2/`?


================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1385
+      if (ExpoIsIntPlusHalf) {
+        Value *Sqrt = emitUnaryFloatFnCall(Base, "sqrt", B,
+                                           Callee->getAttributes());
----------------
Methinks that `s/"sqrt"/TLI->getName(LibFunc_exp2)/` is more elegant.  Additionally, if `pow()` is an intrinsic, you want to emit the intrinsic for `sqrt()` then, rather than a libcall always.  Then, please the corresponding tests too.


https://reviews.llvm.org/D51435





More information about the llvm-commits mailing list