[llvm] [InstCombine] Fold tan(x) * cos(x) => sin(x) (PR #136319)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 19 10:51:31 PDT 2025
================
@@ -947,6 +947,14 @@ Instruction *InstCombinerImpl::foldFMulReassoc(BinaryOperator &I) {
return BinaryOperator::CreateFMulFMF(XX, Y, &I);
}
+ // tan(X) * cos(X) -> sin(X)
+ if (match(&I,
+ m_c_FMul(m_OneUse(m_Intrinsic<Intrinsic::tan>(m_Value(X))),
+ m_OneUse(m_Intrinsic<Intrinsic::cos>(m_Specific(X)))))) {
----------------
amordo wrote:
Should [es44](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es44-dont-depend-on-order-of-evaluation-of-function-arguments) be taken into account? If so `m_Value(X)` must precede the call.
https://github.com/llvm/llvm-project/pull/136319
More information about the llvm-commits
mailing list