Is sorted using SIMD instructions

Per Nordlöw per.nordlow at gmail.com
Thu Apr 12 07:25:27 UTC 2018


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


More information about the Digitalmars-d mailing list