| 1 |
/* Check if conversion for two instructions. */ |
| 2 |
|
| 3 |
/* { dg-do run } */ |
| 4 |
/* { dg-options "-O2 -march=z13 -mzarch --save-temps" } */ |
| 5 |
|
| 6 |
/* { dg-final { scan-assembler "lochi(?:h|nle)\t%r.?,1" } } */ |
| 7 |
/* { dg-final { scan-assembler "locr(?:h|nle)\t.*" } } */ |
| 8 |
#include <stdbool.h> |
| 9 |
#include <limits.h> |
| 10 |
#include <stdio.h> |
| 11 |
#include <assert.h> |
| 12 |
|
| 13 |
__attribute__ ((noinline)) |
| 14 |
int foo (int *a, unsigned int n) |
| 15 |
{ |
| 16 |
int min = 999999; |
| 17 |
bool bla = false; |
| 18 |
for (int i = 0; i < n; i++) |
| 19 |
{ |
| 20 |
if (a[i] < min) |
| 21 |
{ |
| 22 |
min = a[i]; |
| 23 |
bla = true; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
if (bla) |
| 28 |
min += 1; |
| 29 |
return min; |
| 30 |
} |
| 31 |
|
| 32 |
int main() |
| 33 |
{ |
| 34 |
int a[] = {2, 1, -13, INT_MAX, INT_MIN, 0}; |
| 35 |
|
| 36 |
int res = foo (a, sizeof (a)); |
| 37 |
|
| 38 |
assert (res == (INT_MIN + 1)); |
| 39 |
} |