On 12/04/2018 7:25 PM, Per Nordlöw wrote:
Neither GCC, LLVM nor ICC can auto-vectorize (and use SIMD) the seemly
simple function
bool is_sorted(const int32_t* input, size_t n) {
if (n < 2) {
return true;
}
for (size_t i=0; i < n - 1; i++) {
if (input[i] > input[i + 1])
return false;
}
return true;
}
Can D's compilers do better?
See http://0x80.pl/notesen/2018-04-11-simd-is-sorted.html
Just checked, change int to float and it uses ucomiss (SIMD, ldc -O3).
There may not be an instruction for int's.