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

Davide Italiano via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 09:13:17 PST 2017


davide added a comment.

In https://reviews.llvm.org/D28236#634134, @arsenm wrote:

> 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.


Not quite, as that would violate LangRef cos semantic. `http://llvm.org/docs/LangRef.html#llvm-cos-intrinsic`


https://reviews.llvm.org/D28236





More information about the llvm-commits mailing list