| 1 |
/* Make sure if conversion for two instructions does not break |
| 2 |
anything (if it runs). */ |
| 3 |
|
| 4 |
/* { dg-do run } */ |
| 5 |
/* { dg-options "-O2 -std=c99" } */ |
| 6 |
/* { dg-require-effective-target int32plus } */ |
| 7 |
|
| 8 |
#include <limits.h> |
| 9 |
#include <assert.h> |
| 10 |
|
| 11 |
__attribute__ ((noinline)) |
| 12 |
int foo (int *a, int n) |
| 13 |
{ |
| 14 |
int min = 999999; |
| 15 |
int bla = 0; |
| 16 |
for (int i = 0; i < n; i++) |
| 17 |
{ |
| 18 |
if (a[i] < min) |
| 19 |
{ |
| 20 |
min = a[i]; |
| 21 |
bla = 1; |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
if (bla) |
| 26 |
min += 1; |
| 27 |
return min; |
| 28 |
} |
| 29 |
|
| 30 |
int main() |
| 31 |
{ |
| 32 |
int a[] = {2, 1, -13, INT_MAX, INT_MIN, 0}; |
| 33 |
|
| 34 |
int res = foo (a, sizeof (a) / sizeof (a[0])); |
| 35 |
|
| 36 |
assert (res == (INT_MIN + 1)); |
| 37 |
} |