[PATCH] D41286: [InstCombine] Missed optimization in math expression: sin(x) / cos(x) => tan(x)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 13:34:17 PST 2018


spatel added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:1475-1476
+    Value *A;
+    if (match(Op0, m_Intrinsic<Intrinsic::sin>(m_Value(A))) &&
+        match(Op1, m_Intrinsic<Intrinsic::cos>(m_Specific(A)))) {
+      if (hasUnaryFloatFn(&TLI, I.getType(), LibFunc_tan,
----------------
We probably don't want to do this transform if both of the existing values have more than one use; we'd be trading a division for a libcall. If only one value has >1 use, it's probably still ok. Add more tests. :)


https://reviews.llvm.org/D41286





More information about the llvm-commits mailing list