Flipping sign on packed SSE floats

两盒软妹~` 提交于 2019-11-30 11:42:36

Just to complete your own answer by the gcc documentation about these builtin vectors:

The types defined in this manner can be used with a subset of normal C
operations.  Currently, GCC will allow using the following operators on
these types: `+, -, *, /, unary minus, ^, |, &, ~'.

It is probably a good idea to always stick to these when possible. With very high chances gcc will always provide the most efficient code for this SSE stuff.

For your compiler options, add something more specific to your architecture, something like -march=native will do in most cases.

That union is not really needed, best of all worlds (readability, speed and portability):

_mm_xor_ps(vec, _mm_set1_ps(-0.f))

A life lesson about coding till 3am in the morning.....

I never tried just using the unary minus on my packed vector. That actually compiles and has the exact same performance as the non-SIMD approach.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!