[PATCH] D28236: InstCombine: Fold cos(-x) -> cos(x)

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 4 09:35:53 PST 2017


davide requested changes to this revision.
davide added a reviewer: davide.
davide added inline comments.
This revision now requires changes to proceed.


================
Comment at: lib/Transforms/InstCombine/InstCombineCalls.cpp:1643-1649
+    Value *Src = II->getArgOperand(0);
+    if (match(Src, m_FNeg(m_Value(SrcSrc)))) {
+      // cos(-x) -> cos(x)
+      // cos(fabs(x)) -> cos(x)
+      II->setArgOperand(0, SrcSrc);
+      return II;
+    }
----------------
Please match against `fabs` as well here and update the tests.


https://reviews.llvm.org/D28236





More information about the llvm-commits mailing list