[llvm] [InstCombine] Fold tan(x) * cos(x) => sin(x) (PR #136319)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 21 02:35:37 PDT 2025
================
@@ -0,0 +1,136 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes=instcombine < %s | FileCheck %s
+
+define double @fmul_tan_cos(double %a) {
+; CHECK-LABEL: define double @fmul_tan_cos(
+; CHECK-SAME: double [[A:%.*]]) {
+; CHECK-NEXT: [[TAN:%.*]] = call double @llvm.tan.f64(double [[A]])
+; CHECK-NEXT: [[COS:%.*]] = call double @llvm.cos.f64(double [[A]])
+; CHECK-NEXT: [[RES:%.*]] = fmul double [[TAN]], [[COS]]
+; CHECK-NEXT: ret double [[RES]]
+;
+ %tan = call double @llvm.tan.f64(double %a)
+ %cos = call double @llvm.cos.f64(double %a)
+ %res = fmul double %tan, %cos
+ ret double %res
+}
+
----------------
arsenm wrote:
Test vector case, flag preservation, and !fpmath metadata preservation
https://github.com/llvm/llvm-project/pull/136319
More information about the llvm-commits
mailing list