[PATCH] D14302: [SimplifyLibCalls] Add a new transform: tan(atan(x)) -> x

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 3 13:25:47 PST 2015


majnemer added inline comments.

================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1382-1385
@@ +1381,6 @@
+  if (auto *OpC = dyn_cast<CallInst>(Op1)) {
+    IRBuilder<>::FastMathFlagGuard Guard(B);
+    FastMathFlags FMF;
+    FMF.setUnsafeAlgebra();
+    B.SetFastMathFlags(FMF);
+
----------------
No new instructions are created, why is this present?

================
Comment at: lib/Transforms/Utils/SimplifyLibCalls.cpp:1392-1394
@@ +1391,5 @@
+    if (TLI->getLibFunc(FuncName, Func) && TLI->has(Func) &&
+        ((Callee->getName() == "tan" && (Func == LibFunc::atan)) ||
+         (Callee->getName() == "tanf" && (Func == LibFunc::atanf)) ||
+         (Callee->getName() == "tanl" && (Func == LibFunc::atanl))))
+      return OpC->getArgOperand(0);
----------------
The parens around `Func == LibFunc::atan` don't seem necessary.  Also, I'd flip the order of the comparisons so that we are comparing `Func` first.

================
Comment at: test/Transforms/InstCombine/tan.ll:20
@@ +19,2 @@
+attributes #0 = { "unsafe-fp-math"="true" }
+attributes #1 = { "unsafe-fp-math"="true" }
----------------
Attribute `#0` and `#1` are identical, I'd switch all users over to `#0`.


http://reviews.llvm.org/D14302





More information about the llvm-commits mailing list