| 1 |
/* { dg-do compile { target { ! ia32 } } } */ |
| 2 |
/* { dg-skip-if "newlib libc math causes different codegen" { newlib } } */ |
| 3 |
/* { dg-options "-msse4.1 -O2 -Ofast" } */ |
| 4 |
/* { dg-final { scan-assembler-times "roundps" 9 } } */ |
| 5 |
/* { dg-final { scan-assembler-times "cvtps2dq" 1 } } */ |
| 6 |
/* { dg-final { scan-assembler-times "cvttps2dq" 3 } } */ |
| 7 |
|
| 8 |
#include<math.h> |
| 9 |
|
| 10 |
void |
| 11 |
foo (float* p, float* __restrict q) |
| 12 |
{ |
| 13 |
p[0] = truncf (q[0]); |
| 14 |
p[1] = truncf (q[1]); |
| 15 |
} |
| 16 |
|
| 17 |
void |
| 18 |
foo1 (float* p, float* __restrict q) |
| 19 |
{ |
| 20 |
p[0] = floorf (q[0]); |
| 21 |
p[1] = floorf (q[1]); |
| 22 |
} |
| 23 |
|
| 24 |
void |
| 25 |
foo1i (int* p, float* __restrict q) |
| 26 |
{ |
| 27 |
p[0] = (int) floorf (q[0]); |
| 28 |
p[1] = (int) floorf (q[1]); |
| 29 |
} |
| 30 |
|
| 31 |
void |
| 32 |
foo2 (float* p, float* __restrict q) |
| 33 |
{ |
| 34 |
p[0] = ceilf (q[0]); |
| 35 |
p[1] = ceilf (q[1]); |
| 36 |
} |
| 37 |
|
| 38 |
void |
| 39 |
foo2i (int* p, float* __restrict q) |
| 40 |
{ |
| 41 |
p[0] = (int) ceilf (q[0]); |
| 42 |
p[1] = (int) ceilf (q[1]); |
| 43 |
} |
| 44 |
|
| 45 |
void |
| 46 |
foo3 (float* p, float* __restrict q) |
| 47 |
{ |
| 48 |
p[0] = rintf (q[0]); |
| 49 |
p[1] = rintf (q[1]); |
| 50 |
} |
| 51 |
|
| 52 |
void |
| 53 |
foo3i (int* p, float* __restrict q) |
| 54 |
{ |
| 55 |
p[0] = (int) rintf (q[0]); |
| 56 |
p[1] = (int) rintf (q[1]); |
| 57 |
} |
| 58 |
|
| 59 |
void |
| 60 |
foo4 (float* p, float* __restrict q) |
| 61 |
{ |
| 62 |
p[0] = nearbyintf (q[0]); |
| 63 |
p[1] = nearbyintf (q[1]); |
| 64 |
} |
| 65 |
|
| 66 |
void |
| 67 |
foo5(float* p, float* __restrict q) |
| 68 |
{ |
| 69 |
p[0] = roundf (q[0]); |
| 70 |
p[1] = roundf (q[1]); |
| 71 |
} |
| 72 |
|
| 73 |
void |
| 74 |
foo5i(int* p, float* __restrict q) |
| 75 |
{ |
| 76 |
p[0] = (int) roundf (q[0]); |
| 77 |
p[1] = (int) roundf (q[1]); |
| 78 |
} |