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

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 22 08:56:49 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,
----------------
andykaylor wrote:

I don't like `contract` being used for this purpose. I think `contract` should be more predictable and tied to hardware behavior. Historically, we have used `reassoc` for algebraic transformations. If the user has enabled unsafe math optimizations broadly, this sort of optimization is what they'd expect, but if they've only enabled `contract` I don't think it is.

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


More information about the llvm-commits mailing list