1 /* { dg-do compile } */
2 /* { dg-options "-Os -march=r2 -mcdx" } */
3
4 /* Check generation of R2 CDX br.n, beqz.n, bnez.n instructions. */
5
f(int a,int b,int c)6 int f (int a, int b, int c)
7 {
8 if (a == 0)
9 return b;
10 else
11 return c;
12 }
13
g(int a,int b,int c)14 int g (int a, int b, int c)
15 {
16 if (a != 0)
17 return b;
18 else
19 return c;
20 }
21
22 extern int i (int);
23 extern int j (int);
24 extern int k (int);
25
h(int a,int b)26 int h (int a, int b)
27 {
28 int x;
29
30 /* As well as the conditional branch for the "if", there has to be
31 an unconditional branch from one branch of the "if" to
32 the return statement. We compile this testcase with -Os to
33 avoid insertion of a duplicate epilogue in place of the branch. */
34 if (a == b)
35 x = i (37);
36 else
37 x = j (42);
38 return x + a + k (x);
39 }
40
41 /* { dg-final { scan-assembler "\tbeqz\\.n\t.*" } } */
42 /* { dg-final { scan-assembler "\tbnez\\.n\t.*" } } */
43 /* { dg-final { scan-assembler "\tbeq\t|\tbne\t" } } */
44 /* { dg-final { scan-assembler "\tbr\\.n\t.*" } } */
45