Motivation: https://bugs.llvm.org/show_bug.cgi?id=35603. I have failing test on functions cos_acos_fast and sin_asin_fast. Specifically
%call = call fast double @acos(double %a) %call = call fast double @asin(double %a)
are not erased after transform, however %call instruction is never used. I'm looking for help, as I do not know why it behaves this way.
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: