annotate gcc/optabs-tree.c @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Tree-based target query functions relating to optabs
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 1987-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GCC.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
9 version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
14 for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 #include "config.h"
kono
parents:
diff changeset
22 #include "system.h"
kono
parents:
diff changeset
23 #include "coretypes.h"
kono
parents:
diff changeset
24 #include "target.h"
kono
parents:
diff changeset
25 #include "insn-codes.h"
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
26 #include "rtl.h"
111
kono
parents:
diff changeset
27 #include "tree.h"
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
28 #include "memmodel.h"
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
29 #include "optabs.h"
111
kono
parents:
diff changeset
30 #include "optabs-tree.h"
kono
parents:
diff changeset
31 #include "stor-layout.h"
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 /* Return the optab used for computing the operation given by the tree code,
kono
parents:
diff changeset
34 CODE and the tree EXP. This function is not always usable (for example, it
kono
parents:
diff changeset
35 cannot give complete results for multiplication or division) but probably
kono
parents:
diff changeset
36 ought to be relied on more widely throughout the expander. */
kono
parents:
diff changeset
37 optab
kono
parents:
diff changeset
38 optab_for_tree_code (enum tree_code code, const_tree type,
kono
parents:
diff changeset
39 enum optab_subtype subtype)
kono
parents:
diff changeset
40 {
kono
parents:
diff changeset
41 bool trapv;
kono
parents:
diff changeset
42 switch (code)
kono
parents:
diff changeset
43 {
kono
parents:
diff changeset
44 case BIT_AND_EXPR:
kono
parents:
diff changeset
45 return and_optab;
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 case BIT_IOR_EXPR:
kono
parents:
diff changeset
48 return ior_optab;
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 case BIT_NOT_EXPR:
kono
parents:
diff changeset
51 return one_cmpl_optab;
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 case BIT_XOR_EXPR:
kono
parents:
diff changeset
54 return xor_optab;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 case MULT_HIGHPART_EXPR:
kono
parents:
diff changeset
57 return TYPE_UNSIGNED (type) ? umul_highpart_optab : smul_highpart_optab;
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 case TRUNC_MOD_EXPR:
kono
parents:
diff changeset
60 case CEIL_MOD_EXPR:
kono
parents:
diff changeset
61 case FLOOR_MOD_EXPR:
kono
parents:
diff changeset
62 case ROUND_MOD_EXPR:
kono
parents:
diff changeset
63 return TYPE_UNSIGNED (type) ? umod_optab : smod_optab;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 case RDIV_EXPR:
kono
parents:
diff changeset
66 case TRUNC_DIV_EXPR:
kono
parents:
diff changeset
67 case CEIL_DIV_EXPR:
kono
parents:
diff changeset
68 case FLOOR_DIV_EXPR:
kono
parents:
diff changeset
69 case ROUND_DIV_EXPR:
kono
parents:
diff changeset
70 case EXACT_DIV_EXPR:
kono
parents:
diff changeset
71 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
72 return TYPE_UNSIGNED (type) ? usdiv_optab : ssdiv_optab;
kono
parents:
diff changeset
73 return TYPE_UNSIGNED (type) ? udiv_optab : sdiv_optab;
kono
parents:
diff changeset
74
kono
parents:
diff changeset
75 case LSHIFT_EXPR:
kono
parents:
diff changeset
76 if (TREE_CODE (type) == VECTOR_TYPE)
kono
parents:
diff changeset
77 {
kono
parents:
diff changeset
78 if (subtype == optab_vector)
kono
parents:
diff changeset
79 return TYPE_SATURATING (type) ? unknown_optab : vashl_optab;
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 gcc_assert (subtype == optab_scalar);
kono
parents:
diff changeset
82 }
kono
parents:
diff changeset
83 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
84 return TYPE_UNSIGNED (type) ? usashl_optab : ssashl_optab;
kono
parents:
diff changeset
85 return ashl_optab;
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 case RSHIFT_EXPR:
kono
parents:
diff changeset
88 if (TREE_CODE (type) == VECTOR_TYPE)
kono
parents:
diff changeset
89 {
kono
parents:
diff changeset
90 if (subtype == optab_vector)
kono
parents:
diff changeset
91 return TYPE_UNSIGNED (type) ? vlshr_optab : vashr_optab;
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 gcc_assert (subtype == optab_scalar);
kono
parents:
diff changeset
94 }
kono
parents:
diff changeset
95 return TYPE_UNSIGNED (type) ? lshr_optab : ashr_optab;
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 case LROTATE_EXPR:
kono
parents:
diff changeset
98 if (TREE_CODE (type) == VECTOR_TYPE)
kono
parents:
diff changeset
99 {
kono
parents:
diff changeset
100 if (subtype == optab_vector)
kono
parents:
diff changeset
101 return vrotl_optab;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 gcc_assert (subtype == optab_scalar);
kono
parents:
diff changeset
104 }
kono
parents:
diff changeset
105 return rotl_optab;
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 case RROTATE_EXPR:
kono
parents:
diff changeset
108 if (TREE_CODE (type) == VECTOR_TYPE)
kono
parents:
diff changeset
109 {
kono
parents:
diff changeset
110 if (subtype == optab_vector)
kono
parents:
diff changeset
111 return vrotr_optab;
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 gcc_assert (subtype == optab_scalar);
kono
parents:
diff changeset
114 }
kono
parents:
diff changeset
115 return rotr_optab;
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 case MAX_EXPR:
kono
parents:
diff changeset
118 return TYPE_UNSIGNED (type) ? umax_optab : smax_optab;
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 case MIN_EXPR:
kono
parents:
diff changeset
121 return TYPE_UNSIGNED (type) ? umin_optab : smin_optab;
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 case REALIGN_LOAD_EXPR:
kono
parents:
diff changeset
124 return vec_realign_load_optab;
kono
parents:
diff changeset
125
kono
parents:
diff changeset
126 case WIDEN_SUM_EXPR:
kono
parents:
diff changeset
127 return TYPE_UNSIGNED (type) ? usum_widen_optab : ssum_widen_optab;
kono
parents:
diff changeset
128
kono
parents:
diff changeset
129 case DOT_PROD_EXPR:
kono
parents:
diff changeset
130 return TYPE_UNSIGNED (type) ? udot_prod_optab : sdot_prod_optab;
kono
parents:
diff changeset
131
kono
parents:
diff changeset
132 case SAD_EXPR:
kono
parents:
diff changeset
133 return TYPE_UNSIGNED (type) ? usad_optab : ssad_optab;
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 case WIDEN_MULT_PLUS_EXPR:
kono
parents:
diff changeset
136 return (TYPE_UNSIGNED (type)
kono
parents:
diff changeset
137 ? (TYPE_SATURATING (type)
kono
parents:
diff changeset
138 ? usmadd_widen_optab : umadd_widen_optab)
kono
parents:
diff changeset
139 : (TYPE_SATURATING (type)
kono
parents:
diff changeset
140 ? ssmadd_widen_optab : smadd_widen_optab));
kono
parents:
diff changeset
141
kono
parents:
diff changeset
142 case WIDEN_MULT_MINUS_EXPR:
kono
parents:
diff changeset
143 return (TYPE_UNSIGNED (type)
kono
parents:
diff changeset
144 ? (TYPE_SATURATING (type)
kono
parents:
diff changeset
145 ? usmsub_widen_optab : umsub_widen_optab)
kono
parents:
diff changeset
146 : (TYPE_SATURATING (type)
kono
parents:
diff changeset
147 ? ssmsub_widen_optab : smsub_widen_optab));
kono
parents:
diff changeset
148
kono
parents:
diff changeset
149 case VEC_WIDEN_MULT_HI_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
150 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
151 ? vec_widen_umult_hi_optab : vec_widen_smult_hi_optab);
111
kono
parents:
diff changeset
152
kono
parents:
diff changeset
153 case VEC_WIDEN_MULT_LO_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
154 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
155 ? vec_widen_umult_lo_optab : vec_widen_smult_lo_optab);
111
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 case VEC_WIDEN_MULT_EVEN_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
158 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
159 ? vec_widen_umult_even_optab : vec_widen_smult_even_optab);
111
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 case VEC_WIDEN_MULT_ODD_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
162 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
163 ? vec_widen_umult_odd_optab : vec_widen_smult_odd_optab);
111
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 case VEC_WIDEN_LSHIFT_HI_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
166 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
167 ? vec_widen_ushiftl_hi_optab : vec_widen_sshiftl_hi_optab);
111
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 case VEC_WIDEN_LSHIFT_LO_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
170 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
171 ? vec_widen_ushiftl_lo_optab : vec_widen_sshiftl_lo_optab);
111
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 case VEC_UNPACK_HI_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
174 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
175 ? vec_unpacku_hi_optab : vec_unpacks_hi_optab);
111
kono
parents:
diff changeset
176
kono
parents:
diff changeset
177 case VEC_UNPACK_LO_EXPR:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
178 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
179 ? vec_unpacku_lo_optab : vec_unpacks_lo_optab);
111
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 case VEC_UNPACK_FLOAT_HI_EXPR:
kono
parents:
diff changeset
182 /* The signedness is determined from input operand. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
183 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
184 ? vec_unpacku_float_hi_optab : vec_unpacks_float_hi_optab);
111
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 case VEC_UNPACK_FLOAT_LO_EXPR:
kono
parents:
diff changeset
187 /* The signedness is determined from input operand. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
188 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
189 ? vec_unpacku_float_lo_optab : vec_unpacks_float_lo_optab);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
190
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
191 case VEC_UNPACK_FIX_TRUNC_HI_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
192 /* The signedness is determined from output operand. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
193 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
194 ? vec_unpack_ufix_trunc_hi_optab
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
195 : vec_unpack_sfix_trunc_hi_optab);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
196
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
197 case VEC_UNPACK_FIX_TRUNC_LO_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
198 /* The signedness is determined from output operand. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
199 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
200 ? vec_unpack_ufix_trunc_lo_optab
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
201 : vec_unpack_sfix_trunc_lo_optab);
111
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 case VEC_PACK_TRUNC_EXPR:
kono
parents:
diff changeset
204 return vec_pack_trunc_optab;
kono
parents:
diff changeset
205
kono
parents:
diff changeset
206 case VEC_PACK_SAT_EXPR:
kono
parents:
diff changeset
207 return TYPE_UNSIGNED (type) ? vec_pack_usat_optab : vec_pack_ssat_optab;
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 case VEC_PACK_FIX_TRUNC_EXPR:
kono
parents:
diff changeset
210 /* The signedness is determined from output operand. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
211 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
212 ? vec_pack_ufix_trunc_optab : vec_pack_sfix_trunc_optab);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
213
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
214 case VEC_PACK_FLOAT_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
215 /* The signedness is determined from input operand. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
216 return (TYPE_UNSIGNED (type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
217 ? vec_packu_float_optab : vec_packs_float_optab);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
218
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
219 case VEC_DUPLICATE_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
220 return vec_duplicate_optab;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
221
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
222 case VEC_SERIES_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
223 return vec_series_optab;
111
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 default:
kono
parents:
diff changeset
226 break;
kono
parents:
diff changeset
227 }
kono
parents:
diff changeset
228
kono
parents:
diff changeset
229 trapv = INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type);
kono
parents:
diff changeset
230 switch (code)
kono
parents:
diff changeset
231 {
kono
parents:
diff changeset
232 case POINTER_PLUS_EXPR:
kono
parents:
diff changeset
233 case PLUS_EXPR:
kono
parents:
diff changeset
234 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
235 return TYPE_UNSIGNED (type) ? usadd_optab : ssadd_optab;
kono
parents:
diff changeset
236 return trapv ? addv_optab : add_optab;
kono
parents:
diff changeset
237
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
238 case POINTER_DIFF_EXPR:
111
kono
parents:
diff changeset
239 case MINUS_EXPR:
kono
parents:
diff changeset
240 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
241 return TYPE_UNSIGNED (type) ? ussub_optab : sssub_optab;
kono
parents:
diff changeset
242 return trapv ? subv_optab : sub_optab;
kono
parents:
diff changeset
243
kono
parents:
diff changeset
244 case MULT_EXPR:
kono
parents:
diff changeset
245 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
246 return TYPE_UNSIGNED (type) ? usmul_optab : ssmul_optab;
kono
parents:
diff changeset
247 return trapv ? smulv_optab : smul_optab;
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 case NEGATE_EXPR:
kono
parents:
diff changeset
250 if (TYPE_SATURATING (type))
kono
parents:
diff changeset
251 return TYPE_UNSIGNED (type) ? usneg_optab : ssneg_optab;
kono
parents:
diff changeset
252 return trapv ? negv_optab : neg_optab;
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 case ABS_EXPR:
kono
parents:
diff changeset
255 return trapv ? absv_optab : abs_optab;
kono
parents:
diff changeset
256
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
257 case ABSU_EXPR:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
258 return abs_optab;
111
kono
parents:
diff changeset
259 default:
kono
parents:
diff changeset
260 return unknown_optab;
kono
parents:
diff changeset
261 }
kono
parents:
diff changeset
262 }
kono
parents:
diff changeset
263
kono
parents:
diff changeset
264 /* Function supportable_convert_operation
kono
parents:
diff changeset
265
kono
parents:
diff changeset
266 Check whether an operation represented by the code CODE is a
kono
parents:
diff changeset
267 convert operation that is supported by the target platform in
kono
parents:
diff changeset
268 vector form (i.e., when operating on arguments of type VECTYPE_IN
kono
parents:
diff changeset
269 producing a result of type VECTYPE_OUT).
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 Convert operations we currently support directly are FIX_TRUNC and FLOAT.
kono
parents:
diff changeset
272 This function checks if these operations are supported
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
273 by the target platform directly (via vector tree-codes).
111
kono
parents:
diff changeset
274
kono
parents:
diff changeset
275 Output:
kono
parents:
diff changeset
276 - CODE1 is code of vector operation to be used when
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
277 vectorizing the operation, if available. */
111
kono
parents:
diff changeset
278
kono
parents:
diff changeset
279 bool
kono
parents:
diff changeset
280 supportable_convert_operation (enum tree_code code,
kono
parents:
diff changeset
281 tree vectype_out, tree vectype_in,
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
282 enum tree_code *code1)
111
kono
parents:
diff changeset
283 {
kono
parents:
diff changeset
284 machine_mode m1,m2;
kono
parents:
diff changeset
285 bool truncp;
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 m1 = TYPE_MODE (vectype_out);
kono
parents:
diff changeset
288 m2 = TYPE_MODE (vectype_in);
kono
parents:
diff changeset
289
kono
parents:
diff changeset
290 /* First check if we can done conversion directly. */
kono
parents:
diff changeset
291 if ((code == FIX_TRUNC_EXPR
kono
parents:
diff changeset
292 && can_fix_p (m1,m2,TYPE_UNSIGNED (vectype_out), &truncp)
kono
parents:
diff changeset
293 != CODE_FOR_nothing)
kono
parents:
diff changeset
294 || (code == FLOAT_EXPR
kono
parents:
diff changeset
295 && can_float_p (m1,m2,TYPE_UNSIGNED (vectype_in))
kono
parents:
diff changeset
296 != CODE_FOR_nothing))
kono
parents:
diff changeset
297 {
kono
parents:
diff changeset
298 *code1 = code;
kono
parents:
diff changeset
299 return true;
kono
parents:
diff changeset
300 }
kono
parents:
diff changeset
301
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
302 if (GET_MODE_UNIT_PRECISION (m1) > GET_MODE_UNIT_PRECISION (m2)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
303 && can_extend_p (m1, m2, TYPE_UNSIGNED (vectype_in)))
111
kono
parents:
diff changeset
304 {
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
305 *code1 = code;
111
kono
parents:
diff changeset
306 return true;
kono
parents:
diff changeset
307 }
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
308
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
309 if (GET_MODE_UNIT_PRECISION (m1) < GET_MODE_UNIT_PRECISION (m2)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
310 && convert_optab_handler (trunc_optab, m1, m2) != CODE_FOR_nothing)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
311 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
312 *code1 = code;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
313 return true;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
314 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
315
111
kono
parents:
diff changeset
316 return false;
kono
parents:
diff changeset
317 }
kono
parents:
diff changeset
318
kono
parents:
diff changeset
319 /* Return TRUE if appropriate vector insn is available
kono
parents:
diff changeset
320 for vector comparison expr with vector type VALUE_TYPE
kono
parents:
diff changeset
321 and resulting mask with MASK_TYPE. */
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 bool
kono
parents:
diff changeset
324 expand_vec_cmp_expr_p (tree value_type, tree mask_type, enum tree_code code)
kono
parents:
diff changeset
325 {
kono
parents:
diff changeset
326 if (get_vec_cmp_icode (TYPE_MODE (value_type), TYPE_MODE (mask_type),
kono
parents:
diff changeset
327 TYPE_UNSIGNED (value_type)) != CODE_FOR_nothing)
kono
parents:
diff changeset
328 return true;
kono
parents:
diff changeset
329 if ((code == EQ_EXPR || code == NE_EXPR)
kono
parents:
diff changeset
330 && (get_vec_cmp_eq_icode (TYPE_MODE (value_type), TYPE_MODE (mask_type))
kono
parents:
diff changeset
331 != CODE_FOR_nothing))
kono
parents:
diff changeset
332 return true;
kono
parents:
diff changeset
333 return false;
kono
parents:
diff changeset
334 }
kono
parents:
diff changeset
335
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
336 /* Return true iff vcond_optab/vcondu_optab can handle a vector
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
337 comparison for code CODE, comparing operands of type CMP_OP_TYPE and
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
338 producing a result of type VALUE_TYPE. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
339
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
340 static bool
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
341 vcond_icode_p (tree value_type, tree cmp_op_type, enum tree_code code)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
342 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
343 return can_vcond_compare_p (get_rtx_code (code, TYPE_UNSIGNED (cmp_op_type)),
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
344 TYPE_MODE (value_type), TYPE_MODE (cmp_op_type));
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
345 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
346
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
347 /* Return true iff vcondeq_optab can handle a vector comparison for code CODE,
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
348 comparing operands of type CMP_OP_TYPE and producing a result of type
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
349 VALUE_TYPE. */
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
350
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
351 static bool
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
352 vcond_eq_icode_p (tree value_type, tree cmp_op_type, enum tree_code code)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
353 {
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
354 if (code != EQ_EXPR && code != NE_EXPR)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
355 return false;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
356
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
357 return get_vcond_eq_icode (TYPE_MODE (value_type), TYPE_MODE (cmp_op_type))
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
358 != CODE_FOR_nothing;
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
359 }
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
360
111
kono
parents:
diff changeset
361 /* Return TRUE iff, appropriate vector insns are available
kono
parents:
diff changeset
362 for vector cond expr with vector type VALUE_TYPE and a comparison
kono
parents:
diff changeset
363 with operand vector types in CMP_OP_TYPE. */
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 bool
kono
parents:
diff changeset
366 expand_vec_cond_expr_p (tree value_type, tree cmp_op_type, enum tree_code code)
kono
parents:
diff changeset
367 {
kono
parents:
diff changeset
368 machine_mode value_mode = TYPE_MODE (value_type);
kono
parents:
diff changeset
369 machine_mode cmp_op_mode = TYPE_MODE (cmp_op_type);
kono
parents:
diff changeset
370 if (VECTOR_BOOLEAN_TYPE_P (cmp_op_type)
kono
parents:
diff changeset
371 && get_vcond_mask_icode (TYPE_MODE (value_type),
kono
parents:
diff changeset
372 TYPE_MODE (cmp_op_type)) != CODE_FOR_nothing)
kono
parents:
diff changeset
373 return true;
kono
parents:
diff changeset
374
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
375 if (maybe_ne (GET_MODE_SIZE (value_mode), GET_MODE_SIZE (cmp_op_mode))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
376 || maybe_ne (GET_MODE_NUNITS (value_mode), GET_MODE_NUNITS (cmp_op_mode)))
111
kono
parents:
diff changeset
377 return false;
kono
parents:
diff changeset
378
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
379 if (TREE_CODE_CLASS (code) != tcc_comparison)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
380 /* This may happen, for example, if code == SSA_NAME, in which case we
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
381 cannot be certain whether a vector insn is available. */
111
kono
parents:
diff changeset
382 return false;
kono
parents:
diff changeset
383
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
384 return vcond_icode_p (value_type, cmp_op_type, code)
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
385 || vcond_eq_icode_p (value_type, cmp_op_type, code);
111
kono
parents:
diff changeset
386 }
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 /* Use the current target and options to initialize
kono
parents:
diff changeset
389 TREE_OPTIMIZATION_OPTABS (OPTNODE). */
kono
parents:
diff changeset
390
kono
parents:
diff changeset
391 void
kono
parents:
diff changeset
392 init_tree_optimization_optabs (tree optnode)
kono
parents:
diff changeset
393 {
kono
parents:
diff changeset
394 /* Quick exit if we have already computed optabs for this target. */
kono
parents:
diff changeset
395 if (TREE_OPTIMIZATION_BASE_OPTABS (optnode) == this_target_optabs)
kono
parents:
diff changeset
396 return;
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 /* Forget any previous information and set up for the current target. */
kono
parents:
diff changeset
399 TREE_OPTIMIZATION_BASE_OPTABS (optnode) = this_target_optabs;
kono
parents:
diff changeset
400 struct target_optabs *tmp_optabs = (struct target_optabs *)
kono
parents:
diff changeset
401 TREE_OPTIMIZATION_OPTABS (optnode);
kono
parents:
diff changeset
402 if (tmp_optabs)
kono
parents:
diff changeset
403 memset (tmp_optabs, 0, sizeof (struct target_optabs));
kono
parents:
diff changeset
404 else
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
405 tmp_optabs = ggc_cleared_alloc<target_optabs> ();
111
kono
parents:
diff changeset
406
kono
parents:
diff changeset
407 /* Generate a new set of optabs into tmp_optabs. */
kono
parents:
diff changeset
408 init_all_optabs (tmp_optabs);
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410 /* If the optabs changed, record it. */
kono
parents:
diff changeset
411 if (memcmp (tmp_optabs, this_target_optabs, sizeof (struct target_optabs)))
kono
parents:
diff changeset
412 TREE_OPTIMIZATION_OPTABS (optnode) = tmp_optabs;
kono
parents:
diff changeset
413 else
kono
parents:
diff changeset
414 {
kono
parents:
diff changeset
415 TREE_OPTIMIZATION_OPTABS (optnode) = NULL;
kono
parents:
diff changeset
416 ggc_free (tmp_optabs);
kono
parents:
diff changeset
417 }
kono
parents:
diff changeset
418 }
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 /* Return TRUE if the target has support for vector right shift of an
kono
parents:
diff changeset
421 operand of type TYPE. If OT_TYPE is OPTAB_DEFAULT, check for existence
kono
parents:
diff changeset
422 of a shift by either a scalar or a vector. Otherwise, check only
kono
parents:
diff changeset
423 for a shift that matches OT_TYPE. */
kono
parents:
diff changeset
424
kono
parents:
diff changeset
425 bool
kono
parents:
diff changeset
426 target_supports_op_p (tree type, enum tree_code code,
kono
parents:
diff changeset
427 enum optab_subtype ot_subtype)
kono
parents:
diff changeset
428 {
kono
parents:
diff changeset
429 optab ot = optab_for_tree_code (code, type, ot_subtype);
kono
parents:
diff changeset
430 return (ot != unknown_optab
kono
parents:
diff changeset
431 && optab_handler (ot, TYPE_MODE (type)) != CODE_FOR_nothing);
kono
parents:
diff changeset
432 }
kono
parents:
diff changeset
433