| 1 |
/* { dg-do compile { target { ! ia32 } } } */ |
| 2 |
/* { dg-options "-O3 -mno-sse4 -ftree-loop-if-convert" } */ |
| 3 |
|
| 4 |
typedef unsigned long long int uint64_t; |
| 5 |
typedef long long int int64_t; |
| 6 |
int summation_helper_1(int64_t* products, uint64_t count) |
| 7 |
{ |
| 8 |
int s = 0; |
| 9 |
uint64_t i; |
| 10 |
for(i=0; i<count; i++) |
| 11 |
{ |
| 12 |
int64_t val = (products[i]>0) ? 1 : -1; |
| 13 |
products[i] *= val; |
| 14 |
if(products[i] != i) |
| 15 |
val = -val; |
| 16 |
products[i] = val; |
| 17 |
s += val; |
| 18 |
} |
| 19 |
return s; |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
int summation_helper_2(int64_t* products, uint64_t count) |
| 24 |
{ |
| 25 |
int s = 0; |
| 26 |
uint64_t i; |
| 27 |
for(i=0; i<count; i++) |
| 28 |
{ |
| 29 |
int val = (products[i]>0) ? 1 : -1; |
| 30 |
products[i] *= val; |
| 31 |
if(products[i] != i) |
| 32 |
val = -val; |
| 33 |
products[i] = val; |
| 34 |
s += val; |
| 35 |
} |
| 36 |
return s; |
| 37 |
} |
| 38 |
|
| 39 |
/* { dg-final { scan-assembler-times "cmov" 6 } } */ |