MSVC下有调用__libm_sse2_sincos的接口吗?
我目前正在MSVC下对一些C代码进行优化,其中执行一些sin()和cos()计算。
我使用的SSE实现如下:
a = _mm_set_pd(cos(w),sin(w));
但是,当我稍后检查反汇编代码时,我发现微软编译器对cos(w)和sin(w)的解释如下:
call __libm_sse2_cos
...
call __libm_sse2_sin
其中cos和sin是分开调用的。但我希望编译器调用 __libm_sse2_sincos 同时计算具有相同弧度的 sin 和 cos 。
那么我可以告诉编译器这样做吗?或者在MSVC下调用它们的任何接口? Linux下怎么样?
非常感谢您的帮助。
I'm currently working on an optimization of some C codes under MSVC, in which some sin() and cos() calculations are performed.
I use the SSE implementations like:
a = _mm_set_pd(cos(w),sin(w));
However, when I check disassembly codes later, I find that Microsoft compiler interpret cos(w) and sin(w) as follows:
call __libm_sse2_cos
...
call __libm_sse2_sin
In which cos and sin are called separately. But I would expect that compiler call __libm_sse2_sincos to calculate sin and cos with the same radian simultaneously.
So is it possible that I tell compiler to do this? or any interface to call them under MSVC? How about under Linux?
Thanks a lot for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不直接这样做:
?
Why not just do this:
?
如果您想要 MSVC 下的正余弦,您可以使用 XNA 数学库中的实现,即
XMVectorSinCos
和XMScalarSinCos
,它们很糟糕,因为它们是float<仅 /code> 或者您需要使用外部库,例如 AMD 的 LibM(仅适用于 x64)或更短的时间,例如 this。
if you want sincos under MSVC, you can use the implementation(s) from the XNA math library, namely
XMVectorSinCos
andXMScalarSinCos
, which suck as they arefloat
only or you need to use an external library like AMD's LibM (for x64 only) or a smaller time one like this.