| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target cv_bi } */ |
| 3 |
/* { dg-options "-march=rv32i_xcvbi -mabi=ilp32" } */ |
| 4 |
/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ |
| 5 |
|
| 6 |
/* __builtin_expect is used to provide the compiler with |
| 7 |
branch prediction information and to direct the compiler |
| 8 |
to the expected flow through the code. */ |
| 9 |
|
| 10 |
int |
| 11 |
foo1(int a, int x, int y) |
| 12 |
{ |
| 13 |
a = __builtin_expect(a, -16); |
| 14 |
return a == -16 ? x : y; |
| 15 |
} |
| 16 |
|
| 17 |
int |
| 18 |
foo2(int a, int x, int y) |
| 19 |
{ |
| 20 |
a = __builtin_expect(a, 0); |
| 21 |
return a == 0 ? x : y; |
| 22 |
} |
| 23 |
|
| 24 |
int |
| 25 |
foo3(int a, int x, int y) |
| 26 |
{ |
| 27 |
a = __builtin_expect(a, 15); |
| 28 |
return a == 15 ? x : y; |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
foo4(int a, int x, int y) |
| 33 |
{ |
| 34 |
a = __builtin_expect(a, -17); |
| 35 |
return a == -17 ? x : y; |
| 36 |
} |
| 37 |
|
| 38 |
int |
| 39 |
foo5(int a, int x, int y) |
| 40 |
{ |
| 41 |
a = __builtin_expect(a, 16); |
| 42 |
return a == 16 ? x : y; |
| 43 |
} |
| 44 |
|
| 45 |
/* { dg-final { scan-assembler-times "cv\\.bneimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),-16,\(\?\:.L\[0-9\]\)" 1 } } */ |
| 46 |
/* { dg-final { scan-assembler-times "cv\\.bneimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),0,\(\?\:.L\[0-9\]\)" 1 } } */ |
| 47 |
/* { dg-final { scan-assembler-times "cv\\.bneimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),15,\(\?\:.L\[0-9\]\)" 1 } } */ |
| 48 |
/* { dg-final { scan-assembler-times "bne\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),\(\?\:.L\[0-9\]+\)" 2 } } */ |