Dev1an
(Damiaan Dufaux)
2
One thing you could do to eliminate the need of all these bit shifts is to convert your mask of doubles to a mask of UInt8's:
let reducedMask: SIMDMask<SIMD8<UInt8>> = [
cmpresult[0],
cmpresult[1],
cmpresult[2],
cmpresult[3],
cmpresult[4],
cmpresult[5],
cmpresult[6],
cmpresult[7]
]
This reduces the size of your mask from 64bit to 8bit. Then rebind the memory of your mask to a UInt8. and read out that value.
let byte = withUnsafeBytes(of: reducedMask) { $0.bindMemory(to: UInt8.self).baseAddress!.pointee }
I'm not sure that this will result in the performance gains you are looking for, but I hope it's already better than the bitshifting method.
Side note
My way of converting the 64bit mask to 8bit using the array literal still seems a bit like a hack. Maybe there is a better way to do this. Recently, @taylorswift also wrote question about this in: How to convert between SIMD mask types?