blob: bb2e58439577f8a60e5cdaf5a128c9b5346ba58e [file] [log] [blame]
/* { dg-do compile } */
/* { dg-require-effective-target cv_bi } */
/* { dg-options "-march=rv32i_xcvbi -mabi=ilp32" } */
/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
/* __builtin_expect is used to provide the compiler with
branch prediction information and to direct the compiler
to the expected flow through the code. */
int
foo1 (int a, int x, int y)
{
a = __builtin_expect (a, 10);
return a != -16 ? x : y;
}
int
foo2 (int a, int x, int y)
{
a = __builtin_expect (a, 10);
return a != 0 ? x : y;
}
int
foo3 (int a, int x, int y)
{
a = __builtin_expect (a, 10);
return a != 15 ? x : y;
}
int
foo4 (int a, int x, int y)
{
a = __builtin_expect (a, 10);
return a != -17 ? x : y;
}
int
foo5 (int a, int x, int y)
{
a = __builtin_expect (a, 10);
return a != 16 ? x : y;
}
/* { dg-final { scan-assembler-times "cv\\.beqimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),-16,\(\?\:.L\[0-9\]\)" 1 } } */
/* { dg-final { scan-assembler-times "cv\\.beqimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),0,\(\?\:.L\[0-9\]\)" 1 } } */
/* { dg-final { scan-assembler-times "cv\\.beqimm\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),15,\(\?\:.L\[0-9\]\)" 1 } } */
/* { dg-final { scan-assembler-times "beq\t\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),\(\?\:t\[0-6\]\|a\[0-7\]\|s\[1-11\]\),\(\?\:.L\[0-9\]+\)" 2 } } */