1 /* Check that addc and subc patterns are converted if the T value is
2 inverted. */
3 /* { dg-do compile } */
4 /* { dg-options "-O2" } */
5
6 /* { dg-final { scan-assembler-times "cmp/eq" 7 } } */
7
8 /* { dg-final { scan-assembler-times "subc" 5 { target { ! sh2a } } } } */
9 /* { dg-final { scan-assembler-times "not\t" 3 { target { ! sh2a } } } } */
10 /* { dg-final { scan-assembler-times "addc" 2 { target { ! sh2a } } } } */
11
12 /* { dg-final { scan-assembler-times "subc" 2 { target { sh2a } } } } */
13 /* { dg-final { scan-assembler-times "addc" 5 { target { sh2a } } } } */
14 /* { dg-final { scan-assembler-times "nott" 3 { target { sh2a } } } } */
15
16 /* { dg-final { scan-assembler-not "movt" } } */
17 /* { dg-final { scan-assembler-not "negc" } } */
18 /* { dg-final { scan-assembler-not "movrt" } } */
19
20 int
test_0(int a,int b,int c)21 test_0 (int a, int b, int c)
22 {
23 /* 1x cmp/eq, 1x subc */
24 return c + (a != b);
25 }
26
27 int
test_1(int a,int b,int c,int d)28 test_1 (int a, int b, int c, int d)
29 {
30 /* 1x cmp/eq, 1x not, 1x subc
31 SH2A: 1x cmp/eq, 1x nott, 1x addc */
32 return (a != b) + c + d;
33 }
34
35 int
test_2(int a,int b,int c,int d)36 test_2 (int a, int b, int c, int d)
37 {
38 /* 1x cmp/eq, 1x not, 1x subc
39 SH2A: 1x cmp/eq, 1x nott, 1x addc */
40 return c + (a != b) + d;
41 }
42
43 int
test_3(int a,int b,int c,int d)44 test_3 (int a, int b, int c, int d)
45 {
46 /* 1x cmp/eq, 1x not, 1x subc
47 SH2A: 1x cmp/eq, 1x nott, 1x addc */
48 return c + d + (a != b);
49 }
50
51 int
test_4(int a,int b,int c,int d)52 test_4 (int a, int b, int c, int d)
53 {
54 /* 1x cmp/eq, 1x subc */
55 return (a != b) - c;
56 }
57
58 int
test_5(int a,int b,int c,int d)59 test_5 (int a, int b, int c, int d)
60 {
61 /* 1x cmp/eq, 1x add #-1, 1x addc */
62 return c - (a != b);
63 }
64
65 int
test_6(int a,int b,int c,int d)66 test_6 (int a, int b, int c, int d)
67 {
68 /* 1x cmp/eq, 1x add #-1, 1x addc */
69 return c - (a != b) + d;
70 }
71