Reputation: 24414
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.
Upvotes: 2
Views: 2049
Reputation: 471569
Expand my comments into an answer.
Basically you weighing the following trade-off:
Stick with integer:
Convert to floating-point:
float
without precision loss.I'd say stick with integer for now. If you don't want to duplicate code with the float
versions, 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.
Upvotes: 6