[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
Wed Jan 10 12:45:06 PST 2018


spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

I changed the brute force float checker to test 1/tan(x), and it matches cos(x)/sin(x) in all cases on macOS 10.13. This is also true on Ubuntu 17.10 x86-64.

LGTM.



================
Comment at: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:1492-1493
+        match(Op1, m_Intrinsic<Intrinsic::sin>(m_Specific(A)))) {
+      if (hasUnaryFloatFn(&TLI, I.getType(), LibFunc_tan,
+                          LibFunc_tanf, LibFunc_tanl)) {
+        IRBuilder<> B(&I);
----------------
Could hoist this check to the first 'if' to reduce the duplication.


https://reviews.llvm.org/D41286





More information about the llvm-commits mailing list