[AArch64] Add extra add/cast tests for select-optimize.
[llvm-project.git] / compiler-rt / test / builtins / timing / floatundidf.c
blob25c02bd2eab08e0285480ab274bea149952c048e
1 #include "timing.h"
2 #include <stdio.h>
4 #ifndef LIBNAME
5 #define LIBNAME UNKNOWN
6 #endif
8 #define LIBSTRING LIBSTRINGX(LIBNAME)
9 #define LIBSTRINGX(a) LIBSTRINGXX(a)
10 #define LIBSTRINGXX(a) #a
12 double __floatundidf(uint64_t x);
14 int main(int argc, char *argv[]) {
15 #define INPUT_SIZE 512
16 uint64_t input[INPUT_SIZE];
17 int i, j;
19 srand(42);
21 // Initialize the input array with data of various sizes.
22 for (i=0; i<INPUT_SIZE; ++i)
23 input[i] = (((uint64_t)rand() << 32) | (uint64_t)rand()) >> (rand() & 63);
25 double bestTime = __builtin_inf();
26 void *dummyp;
27 for (j=0; j<1024; ++j) {
29 uint64_t startTime = mach_absolute_time();
30 for (i=0; i<INPUT_SIZE; ++i)
31 __floatundidf(input[i]);
32 uint64_t endTime = mach_absolute_time();
34 double thisTime = intervalInCycles(startTime, endTime);
35 bestTime = __builtin_fmin(thisTime, bestTime);
37 // Move the stack alignment between trials to eliminate (mostly) aliasing effects
38 dummyp = alloca(1);
41 printf("%16s: %f cycles.\n", LIBSTRING, bestTime / (double) INPUT_SIZE);
43 return 0;