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

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 09:04:11 PST 2017


arsenm added a comment.

In https://reviews.llvm.org/D28236#634125, @davide wrote:

> `SimplifyLibCalls.cpp` does a similar transformation (`cos(-x) -> cos(x)`).
>  I think we should have the logic for this simplifications in a single place, if possible, so maybe there we should unconditionally lower libc `cos()` -> `llvm.cos` and simplify here?


I think that needs to be part of a larger change to fix the mess of math intrinsic and libcall handling. In the case of cos, I view the cos function as somewhat different from llvm.cos. I expect the intrinsic to be a possibly less precise machine instruction version of cos rather than a fully correct library call so I'm not sure it should always be replaced with the intrinsic.


https://reviews.llvm.org/D28236





More information about the llvm-commits mailing list