2018-02-09 Sebastian Perta <sebastian.perta@renesas.com>
[official-gcc.git] / gcc / testsuite / gcc.target / sh / pr51244-12.c
blobf0c62e6356b28c3a6ac25239dd660466ebd06950
1 /* Check that the negc instruction is generated as expected for the cases
2 below. If we see a movrt or #-1 negc sequence it means that the pattern
3 which handles the inverted case does not work properly. */
4 /* { dg-do compile } */
5 /* { dg-options "-O1" } */
7 /* { dg-final { scan-assembler-times "negc" 15 { target { ! sh2a } } } } */
8 /* { dg-final { scan-assembler-times "addc" 3 { target { ! sh2a } } } } */
10 /* { dg-final { scan-assembler-times "negc" 13 { target { sh2a } } } } */
11 /* { dg-final { scan-assembler-times "addc" 5 { target { sh2a } } } } */
12 /* { dg-final { scan-assembler-times "bld" 2 { target { sh2a } } } } */
14 /* { dg-final { scan-assembler-not "movrt|#-1|add\t|sub\t|movt" } } */
16 int
17 test00 (int a, int b, int* x)
19 return (a == b) ? 0x7FFFFFFF : 0x80000000;
22 int
23 test00_inv (int a, int b)
25 return (a != b) ? 0x80000000 : 0x7FFFFFFF;
28 int
29 test01 (int a, int b)
31 return (a >= b) ? 0x7FFFFFFF : 0x80000000;
34 int
35 test01_inv (int a, int b)
37 return (a < b) ? 0x80000000 : 0x7FFFFFFF;
40 int
41 test02 (int a, int b)
43 return (a > b) ? 0x7FFFFFFF : 0x80000000;
46 int
47 test02_inv (int a, int b)
49 return (a <= b) ? 0x80000000 : 0x7FFFFFFF;
52 int
53 test03 (int a, int b)
55 return ((a & b) == 0) ? 0x7FFFFFFF : 0x80000000;
58 int
59 test03_inv (int a, int b)
61 return ((a & b) != 0) ? 0x80000000 : 0x7FFFFFFF;
64 int
65 test04 (int a)
67 return ((a & 0x55) == 0) ? 0x7FFFFFFF : 0x80000000;
70 int
71 test04_inv (int a)
73 return ((a & 0x55) != 0) ? 0x80000000 : 0x7FFFFFFF;
76 int
77 test05 (int a, int b)
79 /* 1x addc */
80 return a != b ? 0x7FFFFFFF : 0x80000000;
83 int
84 test06 (char a)
86 return ((a & 0x03) == 0) ? 0x7FFFFFFF : 0x80000000;
89 int
90 test07 (char a)
92 return ((a & 0x80) == 0) ? 0x7FFFFFFF : 0x80000000;
95 int
96 test08 (char a)
98 return ((a & 1) == 0) ? 0x7FFFFFFF : 0x80000000;
102 test09 (int a)
104 /* 1x cmp/pz, 1x addc */
105 return a < 0 ? 0x7FFFFFFF : 0x80000000;
109 test10 (int a)
111 /* 1x cmp/pz, 1x negc */
112 return a >= 0 ? 0x7FFFFFFF : 0x80000000;
116 test11 (int a)
118 /* 1x cmp/pl, 1x negc */
119 return a > 0 ? 0x7FFFFFFF : 0x80000000;
123 test12 (int a)
125 /* 1x cmp/pl, 1x addc */
126 return a <= 0 ? 0x7FFFFFFF : 0x80000000;