When dealing with both ints and floats in SSE (AVX) is it a good practice to convert all ints to floats and work only with floats?
Because we need only a few SIMD instructions after that, and all we need to use is addition and compare instructions (<, <=, ==) which this conversion, I hope, should retain completely.
When dealing with both ints and floats in SSE (AVX) is it a good
Share
Expand my comments into an answer.
Basically you weighing the following trade-off:
Stick with integer:
Convert to floating-point:
floatwithout precision loss.I’d say stick with integer for now. If you don’t want to duplicate code with the
floatversions, then that’s your call.The only times I’ve seen where emulating integers with floating-point becomes faster are when you have to do divisions.
Note that I’ve made no mention of readability as diving into manual vectorization probably implies that performance is more important.