Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/imm_choice_comparison.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3 /* { dg-final { check-function-bodies "**" "" } } */
4
5 /* Go from four moves to two. */
6
7 /*
8 ** foo:
9 ** ...
10 ** mov w[0-9]+, 2576980377
11 ** movk x[0-9]+, 0x9999, lsl 32
12 ** ...
13 */
14
15 int
16 foo (long long x)
17 {
18 return x <= 0x0000999999999998;
19 }
20
21 /*
22 ** GT:
23 ** ...
24 ** mov w[0-9]+, -16777217
25 ** ...
26 */
27
28 int
29 GT (unsigned int x)
30 {
31 return x > 0xfefffffe;
32 }
33
34 /*
35 ** LE:
36 ** ...
37 ** mov w[0-9]+, -16777217
38 ** ...
39 */
40
41 int
42 LE (unsigned int x)
43 {
44 return x <= 0xfefffffe;
45 }
46
47 /*
48 ** GE:
49 ** ...
50 ** mov w[0-9]+, 4278190079
51 ** ...
52 */
53
54 int
55 GE (long long x)
56 {
57 return x >= 0xff000000;
58 }
59
60 /*
61 ** LT:
62 ** ...
63 ** mov w[0-9]+, -16777217
64 ** ...
65 */
66
67 int
68 LT (int x)
69 {
70 return x < 0xff000000;
71 }
72
73 /* Optimize the immediate in conditionals. */
74
75 /*
76 ** check:
77 ** ...
78 ** mov w[0-9]+, -16777217
79 ** ...
80 */
81
82 int
83 check (int x, int y)
84 {
85 if (x > y && GT (x))
86 return 100;
87
88 return x;
89 }
90
91 /*
92 ** tern:
93 ** ...
94 ** mov w[0-9]+, -16777217
95 ** ...
96 */
97
98 int
99 tern (int x)
100 {
101 return x >= 0xff000000 ? 5 : -3;
102 }