[llvm] [InstCombine] Fold tan(x) * cos(x) => sin(x) (PR #136319)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 13:09:23 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,
----------------
arsenm wrote:

> What you are suggesting here is, IMO, a significant extension to the way the contract flag is interpreted

It's how the contract flag is already interpreted, see https://discourse.llvm.org/t/rfc-fast-math-flags-semantics-contract/84478

https://github.com/llvm/llvm-project/pull/136319


More information about the llvm-commits mailing list