[PATCH] D41389: [WIP][InstCombine] Missed optimization in math expression: squashing sin(asin), cos(acos)

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 19 18:28:49 PST 2017


hfinkel added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:1273
+    StringRef Name = CallI->getCalledFunction()->getName();
+    if ((II.getIntrinsicID() == Intrinsic::cos && Name == "acos") ||
+        (II.getIntrinsicID() == Intrinsic::sin && Name == "asin")) {
----------------
Don't match function names like this directly (name matching should go through TLI). Something like this:

  LibFunc Func;
  auto *Callee = CallI->getCalledFunction();
  if (!Callee || !TLI->getLibFunc(*Callee, Func) || !TLI->has(Func))
    return nullptr;

  ...

          (II.getIntrinsicID() == Intrinsic::sin && LibFunc == LibFunc_asin)) {

  ...

As it seems like we're likely to get a bunch of these, I recommend adding a matcher for TLI functions so that we can just do:

  match(Src, m_LibCall<LibFunc_asin>(TLI, m_Value(V)))



https://reviews.llvm.org/D41389





More information about the llvm-commits mailing list