]>
Commit | Line | Data |
---|---|---|
48fefb59 | 1 | /* Convert tree expression to rtl instructions, for GNU compiler. |
2 | Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, | |
dc24ddbd | 3 | 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
48fefb59 | 4 | |
5 | This file is part of GCC. | |
6 | ||
7 | GCC is free software; you can redistribute it and/or modify it under | |
8 | the terms of the GNU General Public License as published by the Free | |
9 | Software Foundation; either version 2, or (at your option) any later | |
10 | version. | |
11 | ||
12 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY | |
13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 | for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with GCC; see the file COPYING. If not, write to the Free | |
19 | Software Foundation, 59 Temple Place - Suite 330, Boston, MA | |
20 | 02111-1307, USA. */ | |
21 | ||
22 | #include "config.h" | |
23 | #include "system.h" | |
24 | #include "coretypes.h" | |
25 | #include "tm.h" | |
26 | #include "rtl.h" | |
27 | #include "tree.h" | |
28 | #include "flags.h" | |
29 | #include "function.h" | |
30 | #include "insn-config.h" | |
31 | #include "insn-attr.h" | |
32 | /* Include expr.h after insn-config.h so we get HAVE_conditional_move. */ | |
33 | #include "expr.h" | |
34 | #include "optabs.h" | |
35 | #include "langhooks.h" | |
d9e19419 | 36 | #include "ggc.h" |
48fefb59 | 37 | |
d9e19419 | 38 | static bool prefer_and_bit_test (enum machine_mode, int); |
8ec3a57b | 39 | static void do_jump_by_parts_greater (tree, int, rtx, rtx); |
40 | static void do_jump_by_parts_equality (tree, rtx, rtx); | |
41 | static void do_compare_and_jump (tree, enum rtx_code, enum rtx_code, rtx, | |
42 | rtx); | |
48fefb59 | 43 | |
44 | /* At the start of a function, record that we have no previously-pushed | |
45 | arguments waiting to be popped. */ | |
46 | ||
47 | void | |
8ec3a57b | 48 | init_pending_stack_adjust (void) |
48fefb59 | 49 | { |
50 | pending_stack_adjust = 0; | |
51 | } | |
52 | ||
53 | /* When exiting from function, if safe, clear out any pending stack adjust | |
54 | so the adjustment won't get done. | |
55 | ||
56 | Note, if the current function calls alloca, then it must have a | |
57 | frame pointer regardless of the value of flag_omit_frame_pointer. */ | |
58 | ||
59 | void | |
8ec3a57b | 60 | clear_pending_stack_adjust (void) |
48fefb59 | 61 | { |
48fefb59 | 62 | if (optimize > 0 |
63 | && (! flag_omit_frame_pointer || current_function_calls_alloca) | |
64 | && EXIT_IGNORE_STACK | |
65 | && ! (DECL_INLINE (current_function_decl) && ! flag_no_inline) | |
66 | && ! flag_inline_functions) | |
67 | { | |
68 | stack_pointer_delta -= pending_stack_adjust, | |
69 | pending_stack_adjust = 0; | |
70 | } | |
48fefb59 | 71 | } |
72 | ||
73 | /* Pop any previously-pushed arguments that have not been popped yet. */ | |
74 | ||
75 | void | |
8ec3a57b | 76 | do_pending_stack_adjust (void) |
48fefb59 | 77 | { |
78 | if (inhibit_defer_pop == 0) | |
79 | { | |
80 | if (pending_stack_adjust != 0) | |
81 | adjust_stack (GEN_INT (pending_stack_adjust)); | |
82 | pending_stack_adjust = 0; | |
83 | } | |
84 | } | |
85 | \f | |
86 | /* Expand conditional expressions. */ | |
87 | ||
88 | /* Generate code to evaluate EXP and jump to LABEL if the value is zero. | |
89 | LABEL is an rtx of code CODE_LABEL, in this function and all the | |
90 | functions here. */ | |
91 | ||
92 | void | |
8ec3a57b | 93 | jumpifnot (tree exp, rtx label) |
48fefb59 | 94 | { |
95 | do_jump (exp, label, NULL_RTX); | |
96 | } | |
97 | ||
98 | /* Generate code to evaluate EXP and jump to LABEL if the value is nonzero. */ | |
99 | ||
100 | void | |
8ec3a57b | 101 | jumpif (tree exp, rtx label) |
48fefb59 | 102 | { |
103 | do_jump (exp, NULL_RTX, label); | |
104 | } | |
105 | ||
d9e19419 | 106 | /* Used internally by prefer_and_bit_test. */ |
107 | ||
108 | static GTY(()) rtx and_reg; | |
109 | static GTY(()) rtx and_test; | |
110 | static GTY(()) rtx shift_test; | |
111 | ||
112 | /* Compare the relative costs of "(X & (1 << BITNUM))" and "(X >> BITNUM) & 1", | |
113 | where X is an arbitrary register of mode MODE. Return true if the former | |
114 | is preferred. */ | |
115 | ||
116 | static bool | |
117 | prefer_and_bit_test (enum machine_mode mode, int bitnum) | |
118 | { | |
119 | if (and_test == 0) | |
120 | { | |
121 | /* Set up rtxes for the two variations. Use NULL as a placeholder | |
122 | for the BITNUM-based constants. */ | |
123 | and_reg = gen_rtx_REG (mode, FIRST_PSEUDO_REGISTER); | |
124 | and_test = gen_rtx_AND (mode, and_reg, NULL); | |
125 | shift_test = gen_rtx_AND (mode, gen_rtx_ASHIFTRT (mode, and_reg, NULL), | |
126 | const1_rtx); | |
127 | } | |
128 | else | |
129 | { | |
130 | /* Change the mode of the previously-created rtxes. */ | |
131 | PUT_MODE (and_reg, mode); | |
132 | PUT_MODE (and_test, mode); | |
133 | PUT_MODE (shift_test, mode); | |
134 | PUT_MODE (XEXP (shift_test, 0), mode); | |
135 | } | |
136 | ||
137 | /* Fill in the integers. */ | |
c4c17cb1 | 138 | XEXP (and_test, 1) = GEN_INT ((unsigned HOST_WIDE_INT) 1 << bitnum); |
d9e19419 | 139 | XEXP (XEXP (shift_test, 0), 1) = GEN_INT (bitnum); |
140 | ||
141 | return (rtx_cost (and_test, IF_THEN_ELSE) | |
142 | <= rtx_cost (shift_test, IF_THEN_ELSE)); | |
143 | } | |
144 | ||
48fefb59 | 145 | /* Generate code to evaluate EXP and jump to IF_FALSE_LABEL if |
146 | the result is zero, or IF_TRUE_LABEL if the result is one. | |
147 | Either of IF_FALSE_LABEL and IF_TRUE_LABEL may be zero, | |
148 | meaning fall through in that case. | |
149 | ||
150 | do_jump always does any pending stack adjust except when it does not | |
151 | actually perform a jump. An example where there is no jump | |
152 | is when EXP is `(foo (), 0)' and IF_FALSE_LABEL is null. | |
153 | ||
154 | This function is responsible for optimizing cases such as | |
155 | &&, || and comparison operators in EXP. */ | |
156 | ||
157 | void | |
8ec3a57b | 158 | do_jump (tree exp, rtx if_false_label, rtx if_true_label) |
48fefb59 | 159 | { |
160 | enum tree_code code = TREE_CODE (exp); | |
161 | /* Some cases need to create a label to jump to | |
162 | in order to properly fall through. | |
163 | These cases set DROP_THROUGH_LABEL nonzero. */ | |
164 | rtx drop_through_label = 0; | |
165 | rtx temp; | |
166 | int i; | |
167 | tree type; | |
168 | enum machine_mode mode; | |
169 | ||
48fefb59 | 170 | switch (code) |
171 | { | |
172 | case ERROR_MARK: | |
173 | break; | |
174 | ||
175 | case INTEGER_CST: | |
176 | temp = integer_zerop (exp) ? if_false_label : if_true_label; | |
177 | if (temp) | |
178 | emit_jump (temp); | |
179 | break; | |
180 | ||
181 | #if 0 | |
182 | /* This is not true with #pragma weak */ | |
183 | case ADDR_EXPR: | |
184 | /* The address of something can never be zero. */ | |
185 | if (if_true_label) | |
186 | emit_jump (if_true_label); | |
187 | break; | |
188 | #endif | |
189 | ||
190 | case NOP_EXPR: | |
191 | if (TREE_CODE (TREE_OPERAND (exp, 0)) == COMPONENT_REF | |
192 | || TREE_CODE (TREE_OPERAND (exp, 0)) == BIT_FIELD_REF | |
193 | || TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_REF | |
194 | || TREE_CODE (TREE_OPERAND (exp, 0)) == ARRAY_RANGE_REF) | |
195 | goto normal; | |
196 | case CONVERT_EXPR: | |
197 | /* If we are narrowing the operand, we have to do the compare in the | |
198 | narrower mode. */ | |
199 | if ((TYPE_PRECISION (TREE_TYPE (exp)) | |
200 | < TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (exp, 0))))) | |
201 | goto normal; | |
202 | case NON_LVALUE_EXPR: | |
48fefb59 | 203 | case ABS_EXPR: |
204 | case NEGATE_EXPR: | |
205 | case LROTATE_EXPR: | |
206 | case RROTATE_EXPR: | |
207 | /* These cannot change zero->nonzero or vice versa. */ | |
208 | do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label); | |
209 | break; | |
210 | ||
48fefb59 | 211 | #if 0 |
212 | /* This is never less insns than evaluating the PLUS_EXPR followed by | |
213 | a test and can be longer if the test is eliminated. */ | |
214 | case PLUS_EXPR: | |
215 | /* Reduce to minus. */ | |
b55f9493 | 216 | exp = build2 (MINUS_EXPR, TREE_TYPE (exp), |
217 | TREE_OPERAND (exp, 0), | |
218 | fold (build1 (NEGATE_EXPR, | |
219 | TREE_TYPE (TREE_OPERAND (exp, 1)), | |
220 | TREE_OPERAND (exp, 1)))); | |
48fefb59 | 221 | /* Process as MINUS. */ |
222 | #endif | |
223 | ||
224 | case MINUS_EXPR: | |
225 | /* Nonzero iff operands of minus differ. */ | |
b55f9493 | 226 | do_compare_and_jump (build2 (NE_EXPR, TREE_TYPE (exp), |
227 | TREE_OPERAND (exp, 0), | |
228 | TREE_OPERAND (exp, 1)), | |
48fefb59 | 229 | NE, NE, if_false_label, if_true_label); |
230 | break; | |
231 | ||
232 | case BIT_AND_EXPR: | |
d9e19419 | 233 | /* fold_single_bit_test() converts (X & (1 << C)) into (X >> C) & 1. |
234 | See if the former is preferred for jump tests and restore it | |
235 | if so. */ | |
236 | if (TREE_CODE (TREE_OPERAND (exp, 0)) == RSHIFT_EXPR | |
237 | && integer_onep (TREE_OPERAND (exp, 1))) | |
238 | { | |
239 | tree arg = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); | |
240 | tree shift = TREE_OPERAND (TREE_OPERAND (exp, 0), 1); | |
241 | tree one = TREE_OPERAND (exp, 1); | |
242 | tree argtype = TREE_TYPE (arg); | |
243 | if (TREE_CODE (shift) == INTEGER_CST | |
244 | && compare_tree_int (shift, 0) > 0 | |
245 | && compare_tree_int (shift, HOST_BITS_PER_WIDE_INT) < 0 | |
246 | && prefer_and_bit_test (TYPE_MODE (argtype), | |
247 | TREE_INT_CST_LOW (shift))) | |
248 | { | |
b55f9493 | 249 | do_jump (build2 (BIT_AND_EXPR, argtype, arg, |
250 | fold (build2 (LSHIFT_EXPR, argtype, | |
251 | one, shift))), | |
d9e19419 | 252 | if_false_label, if_true_label); |
253 | break; | |
254 | } | |
255 | } | |
256 | ||
48fefb59 | 257 | /* If we are AND'ing with a small constant, do this comparison in the |
258 | smallest type that fits. If the machine doesn't have comparisons | |
259 | that small, it will be converted back to the wider comparison. | |
260 | This helps if we are testing the sign bit of a narrower object. | |
261 | combine can't do this for us because it can't know whether a | |
262 | ZERO_EXTRACT or a compare in a smaller mode exists, but we do. */ | |
263 | ||
264 | if (! SLOW_BYTE_ACCESS | |
265 | && TREE_CODE (TREE_OPERAND (exp, 1)) == INTEGER_CST | |
266 | && TYPE_PRECISION (TREE_TYPE (exp)) <= HOST_BITS_PER_WIDE_INT | |
267 | && (i = tree_floor_log2 (TREE_OPERAND (exp, 1))) >= 0 | |
268 | && (mode = mode_for_size (i + 1, MODE_INT, 0)) != BLKmode | |
dc24ddbd | 269 | && (type = lang_hooks.types.type_for_mode (mode, 1)) != 0 |
48fefb59 | 270 | && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp)) |
271 | && (cmp_optab->handlers[(int) TYPE_MODE (type)].insn_code | |
272 | != CODE_FOR_nothing)) | |
273 | { | |
274 | do_jump (convert (type, exp), if_false_label, if_true_label); | |
275 | break; | |
276 | } | |
277 | goto normal; | |
278 | ||
279 | case TRUTH_NOT_EXPR: | |
280 | do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label); | |
281 | break; | |
282 | ||
283 | case TRUTH_ANDIF_EXPR: | |
284 | if (if_false_label == 0) | |
285 | if_false_label = drop_through_label = gen_label_rtx (); | |
286 | do_jump (TREE_OPERAND (exp, 0), if_false_label, NULL_RTX); | |
48fefb59 | 287 | do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label); |
48fefb59 | 288 | break; |
289 | ||
290 | case TRUTH_ORIF_EXPR: | |
291 | if (if_true_label == 0) | |
292 | if_true_label = drop_through_label = gen_label_rtx (); | |
293 | do_jump (TREE_OPERAND (exp, 0), NULL_RTX, if_true_label); | |
48fefb59 | 294 | do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label); |
48fefb59 | 295 | break; |
296 | ||
297 | case COMPOUND_EXPR: | |
298 | push_temp_slots (); | |
299 | expand_expr (TREE_OPERAND (exp, 0), const0_rtx, VOIDmode, 0); | |
300 | preserve_temp_slots (NULL_RTX); | |
301 | free_temp_slots (); | |
302 | pop_temp_slots (); | |
48fefb59 | 303 | do_pending_stack_adjust (); |
304 | do_jump (TREE_OPERAND (exp, 1), if_false_label, if_true_label); | |
305 | break; | |
306 | ||
307 | case COMPONENT_REF: | |
308 | case BIT_FIELD_REF: | |
309 | case ARRAY_REF: | |
310 | case ARRAY_RANGE_REF: | |
311 | { | |
312 | HOST_WIDE_INT bitsize, bitpos; | |
313 | int unsignedp; | |
314 | enum machine_mode mode; | |
315 | tree type; | |
316 | tree offset; | |
317 | int volatilep = 0; | |
318 | ||
319 | /* Get description of this reference. We don't actually care | |
320 | about the underlying object here. */ | |
321 | get_inner_reference (exp, &bitsize, &bitpos, &offset, &mode, | |
322 | &unsignedp, &volatilep); | |
323 | ||
dc24ddbd | 324 | type = lang_hooks.types.type_for_size (bitsize, unsignedp); |
48fefb59 | 325 | if (! SLOW_BYTE_ACCESS |
326 | && type != 0 && bitsize >= 0 | |
327 | && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (exp)) | |
328 | && (cmp_optab->handlers[(int) TYPE_MODE (type)].insn_code | |
7ece5e4f | 329 | != CODE_FOR_nothing)) |
48fefb59 | 330 | { |
331 | do_jump (convert (type, exp), if_false_label, if_true_label); | |
332 | break; | |
333 | } | |
334 | goto normal; | |
335 | } | |
336 | ||
337 | case COND_EXPR: | |
338 | /* Do (a ? 1 : 0) and (a ? 0 : 1) as special cases. */ | |
339 | if (integer_onep (TREE_OPERAND (exp, 1)) | |
340 | && integer_zerop (TREE_OPERAND (exp, 2))) | |
341 | do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label); | |
342 | ||
343 | else if (integer_zerop (TREE_OPERAND (exp, 1)) | |
344 | && integer_onep (TREE_OPERAND (exp, 2))) | |
345 | do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label); | |
346 | ||
347 | else | |
348 | { | |
349 | rtx label1 = gen_label_rtx (); | |
350 | drop_through_label = gen_label_rtx (); | |
351 | ||
352 | do_jump (TREE_OPERAND (exp, 0), label1, NULL_RTX); | |
353 | ||
48fefb59 | 354 | /* Now the THEN-expression. */ |
355 | do_jump (TREE_OPERAND (exp, 1), | |
356 | if_false_label ? if_false_label : drop_through_label, | |
357 | if_true_label ? if_true_label : drop_through_label); | |
358 | /* In case the do_jump just above never jumps. */ | |
359 | do_pending_stack_adjust (); | |
360 | emit_label (label1); | |
361 | ||
362 | /* Now the ELSE-expression. */ | |
363 | do_jump (TREE_OPERAND (exp, 2), | |
364 | if_false_label ? if_false_label : drop_through_label, | |
365 | if_true_label ? if_true_label : drop_through_label); | |
48fefb59 | 366 | } |
367 | break; | |
368 | ||
369 | case EQ_EXPR: | |
370 | { | |
371 | tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0)); | |
372 | ||
373 | if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_FLOAT | |
374 | || GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_INT) | |
375 | { | |
376 | tree exp0 = save_expr (TREE_OPERAND (exp, 0)); | |
377 | tree exp1 = save_expr (TREE_OPERAND (exp, 1)); | |
378 | do_jump | |
379 | (fold | |
b55f9493 | 380 | (build2 (TRUTH_ANDIF_EXPR, TREE_TYPE (exp), |
381 | fold (build2 (EQ_EXPR, TREE_TYPE (exp), | |
48fefb59 | 382 | fold (build1 (REALPART_EXPR, |
383 | TREE_TYPE (inner_type), | |
384 | exp0)), | |
385 | fold (build1 (REALPART_EXPR, | |
386 | TREE_TYPE (inner_type), | |
387 | exp1)))), | |
b55f9493 | 388 | fold (build2 (EQ_EXPR, TREE_TYPE (exp), |
48fefb59 | 389 | fold (build1 (IMAGPART_EXPR, |
390 | TREE_TYPE (inner_type), | |
391 | exp0)), | |
392 | fold (build1 (IMAGPART_EXPR, | |
393 | TREE_TYPE (inner_type), | |
394 | exp1)))))), | |
395 | if_false_label, if_true_label); | |
396 | } | |
397 | ||
398 | else if (integer_zerop (TREE_OPERAND (exp, 1))) | |
399 | do_jump (TREE_OPERAND (exp, 0), if_true_label, if_false_label); | |
400 | ||
401 | else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT | |
402 | && !can_compare_p (EQ, TYPE_MODE (inner_type), ccp_jump)) | |
403 | do_jump_by_parts_equality (exp, if_false_label, if_true_label); | |
404 | else | |
405 | do_compare_and_jump (exp, EQ, EQ, if_false_label, if_true_label); | |
406 | break; | |
407 | } | |
408 | ||
409 | case NE_EXPR: | |
410 | { | |
411 | tree inner_type = TREE_TYPE (TREE_OPERAND (exp, 0)); | |
412 | ||
413 | if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_FLOAT | |
414 | || GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_COMPLEX_INT) | |
415 | { | |
416 | tree exp0 = save_expr (TREE_OPERAND (exp, 0)); | |
417 | tree exp1 = save_expr (TREE_OPERAND (exp, 1)); | |
418 | do_jump | |
419 | (fold | |
b55f9493 | 420 | (build2 (TRUTH_ORIF_EXPR, TREE_TYPE (exp), |
421 | fold (build2 (NE_EXPR, TREE_TYPE (exp), | |
48fefb59 | 422 | fold (build1 (REALPART_EXPR, |
423 | TREE_TYPE (inner_type), | |
424 | exp0)), | |
425 | fold (build1 (REALPART_EXPR, | |
426 | TREE_TYPE (inner_type), | |
427 | exp1)))), | |
b55f9493 | 428 | fold (build2 (NE_EXPR, TREE_TYPE (exp), |
48fefb59 | 429 | fold (build1 (IMAGPART_EXPR, |
430 | TREE_TYPE (inner_type), | |
431 | exp0)), | |
432 | fold (build1 (IMAGPART_EXPR, | |
433 | TREE_TYPE (inner_type), | |
434 | exp1)))))), | |
435 | if_false_label, if_true_label); | |
436 | } | |
437 | ||
438 | else if (integer_zerop (TREE_OPERAND (exp, 1))) | |
439 | do_jump (TREE_OPERAND (exp, 0), if_false_label, if_true_label); | |
440 | ||
441 | else if (GET_MODE_CLASS (TYPE_MODE (inner_type)) == MODE_INT | |
442 | && !can_compare_p (NE, TYPE_MODE (inner_type), ccp_jump)) | |
443 | do_jump_by_parts_equality (exp, if_true_label, if_false_label); | |
444 | else | |
445 | do_compare_and_jump (exp, NE, NE, if_false_label, if_true_label); | |
446 | break; | |
447 | } | |
448 | ||
449 | case LT_EXPR: | |
450 | mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))); | |
451 | if (GET_MODE_CLASS (mode) == MODE_INT | |
452 | && ! can_compare_p (LT, mode, ccp_jump)) | |
453 | do_jump_by_parts_greater (exp, 1, if_false_label, if_true_label); | |
454 | else | |
455 | do_compare_and_jump (exp, LT, LTU, if_false_label, if_true_label); | |
456 | break; | |
457 | ||
458 | case LE_EXPR: | |
459 | mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))); | |
460 | if (GET_MODE_CLASS (mode) == MODE_INT | |
461 | && ! can_compare_p (LE, mode, ccp_jump)) | |
462 | do_jump_by_parts_greater (exp, 0, if_true_label, if_false_label); | |
463 | else | |
464 | do_compare_and_jump (exp, LE, LEU, if_false_label, if_true_label); | |
465 | break; | |
466 | ||
467 | case GT_EXPR: | |
468 | mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))); | |
469 | if (GET_MODE_CLASS (mode) == MODE_INT | |
470 | && ! can_compare_p (GT, mode, ccp_jump)) | |
471 | do_jump_by_parts_greater (exp, 0, if_false_label, if_true_label); | |
472 | else | |
473 | do_compare_and_jump (exp, GT, GTU, if_false_label, if_true_label); | |
474 | break; | |
475 | ||
476 | case GE_EXPR: | |
477 | mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))); | |
478 | if (GET_MODE_CLASS (mode) == MODE_INT | |
479 | && ! can_compare_p (GE, mode, ccp_jump)) | |
480 | do_jump_by_parts_greater (exp, 1, if_true_label, if_false_label); | |
481 | else | |
482 | do_compare_and_jump (exp, GE, GEU, if_false_label, if_true_label); | |
483 | break; | |
484 | ||
485 | case UNORDERED_EXPR: | |
486 | case ORDERED_EXPR: | |
487 | { | |
488 | enum rtx_code cmp, rcmp; | |
489 | int do_rev; | |
490 | ||
491 | if (code == UNORDERED_EXPR) | |
492 | cmp = UNORDERED, rcmp = ORDERED; | |
493 | else | |
494 | cmp = ORDERED, rcmp = UNORDERED; | |
495 | mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))); | |
496 | ||
497 | do_rev = 0; | |
498 | if (! can_compare_p (cmp, mode, ccp_jump) | |
499 | && (can_compare_p (rcmp, mode, ccp_jump) | |
500 | /* If the target doesn't provide either UNORDERED or ORDERED | |
501 | comparisons, canonicalize on UNORDERED for the library. */ | |
502 | || rcmp == UNORDERED)) | |
503 | do_rev = 1; | |
504 | ||
505 | if (! do_rev) | |
506 | do_compare_and_jump (exp, cmp, cmp, if_false_label, if_true_label); | |
507 | else | |
508 | do_compare_and_jump (exp, rcmp, rcmp, if_true_label, if_false_label); | |
509 | } | |
510 | break; | |
511 | ||
512 | { | |
513 | enum rtx_code rcode1; | |
458e2bb2 | 514 | enum tree_code tcode1, tcode2; |
48fefb59 | 515 | |
516 | case UNLT_EXPR: | |
517 | rcode1 = UNLT; | |
458e2bb2 | 518 | tcode1 = UNORDERED_EXPR; |
48fefb59 | 519 | tcode2 = LT_EXPR; |
520 | goto unordered_bcc; | |
521 | case UNLE_EXPR: | |
522 | rcode1 = UNLE; | |
458e2bb2 | 523 | tcode1 = UNORDERED_EXPR; |
48fefb59 | 524 | tcode2 = LE_EXPR; |
525 | goto unordered_bcc; | |
526 | case UNGT_EXPR: | |
527 | rcode1 = UNGT; | |
458e2bb2 | 528 | tcode1 = UNORDERED_EXPR; |
48fefb59 | 529 | tcode2 = GT_EXPR; |
530 | goto unordered_bcc; | |
531 | case UNGE_EXPR: | |
532 | rcode1 = UNGE; | |
458e2bb2 | 533 | tcode1 = UNORDERED_EXPR; |
48fefb59 | 534 | tcode2 = GE_EXPR; |
535 | goto unordered_bcc; | |
536 | case UNEQ_EXPR: | |
537 | rcode1 = UNEQ; | |
458e2bb2 | 538 | tcode1 = UNORDERED_EXPR; |
48fefb59 | 539 | tcode2 = EQ_EXPR; |
540 | goto unordered_bcc; | |
318a728f | 541 | case LTGT_EXPR: |
542 | /* It is ok for LTGT_EXPR to trap when the result is unordered, | |
543 | so expand to (a < b) || (a > b). */ | |
544 | rcode1 = LTGT; | |
545 | tcode1 = LT_EXPR; | |
546 | tcode2 = GT_EXPR; | |
547 | goto unordered_bcc; | |
48fefb59 | 548 | |
549 | unordered_bcc: | |
550 | mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))); | |
551 | if (can_compare_p (rcode1, mode, ccp_jump)) | |
552 | do_compare_and_jump (exp, rcode1, rcode1, if_false_label, | |
553 | if_true_label); | |
554 | else | |
555 | { | |
556 | tree op0 = save_expr (TREE_OPERAND (exp, 0)); | |
557 | tree op1 = save_expr (TREE_OPERAND (exp, 1)); | |
558 | tree cmp0, cmp1; | |
559 | ||
560 | /* If the target doesn't support combined unordered | |
318a728f | 561 | compares, decompose into two comparisons. */ |
b55f9493 | 562 | cmp0 = fold (build2 (tcode1, TREE_TYPE (exp), op0, op1)); |
563 | cmp1 = fold (build2 (tcode2, TREE_TYPE (exp), op0, op1)); | |
564 | exp = build2 (TRUTH_ORIF_EXPR, TREE_TYPE (exp), cmp0, cmp1); | |
48fefb59 | 565 | do_jump (exp, if_false_label, if_true_label); |
566 | } | |
567 | } | |
568 | break; | |
569 | ||
570 | /* Special case: | |
571 | __builtin_expect (<test>, 0) and | |
572 | __builtin_expect (<test>, 1) | |
573 | ||
574 | We need to do this here, so that <test> is not converted to a SCC | |
575 | operation on machines that use condition code registers and COMPARE | |
576 | like the PowerPC, and then the jump is done based on whether the SCC | |
577 | operation produced a 1 or 0. */ | |
578 | case CALL_EXPR: | |
579 | /* Check for a built-in function. */ | |
c6e6ecb1 | 580 | { |
581 | tree fndecl = get_callee_fndecl (exp); | |
582 | tree arglist = TREE_OPERAND (exp, 1); | |
583 | ||
584 | if (fndecl | |
585 | && DECL_BUILT_IN (fndecl) | |
586 | && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT | |
587 | && arglist != NULL_TREE | |
588 | && TREE_CHAIN (arglist) != NULL_TREE) | |
589 | { | |
590 | rtx seq = expand_builtin_expect_jump (exp, if_false_label, | |
591 | if_true_label); | |
592 | ||
593 | if (seq != NULL_RTX) | |
594 | { | |
595 | emit_insn (seq); | |
596 | return; | |
597 | } | |
598 | } | |
599 | } | |
b4b174c3 | 600 | /* Fall through and generate the normal code. */ |
48fefb59 | 601 | |
602 | default: | |
603 | normal: | |
604 | temp = expand_expr (exp, NULL_RTX, VOIDmode, 0); | |
605 | #if 0 | |
606 | /* This is not needed any more and causes poor code since it causes | |
607 | comparisons and tests from non-SI objects to have different code | |
608 | sequences. */ | |
609 | /* Copy to register to avoid generating bad insns by cse | |
610 | from (set (mem ...) (arithop)) (set (cc0) (mem ...)). */ | |
e16ceb8e | 611 | if (!cse_not_expected && MEM_P (temp)) |
48fefb59 | 612 | temp = copy_to_reg (temp); |
613 | #endif | |
614 | do_pending_stack_adjust (); | |
48fefb59 | 615 | |
616 | if (GET_CODE (temp) == CONST_INT | |
617 | || (GET_CODE (temp) == CONST_DOUBLE && GET_MODE (temp) == VOIDmode) | |
618 | || GET_CODE (temp) == LABEL_REF) | |
619 | { | |
620 | rtx target = temp == const0_rtx ? if_false_label : if_true_label; | |
621 | if (target) | |
622 | emit_jump (target); | |
623 | } | |
624 | else if (GET_MODE_CLASS (GET_MODE (temp)) == MODE_INT | |
625 | && ! can_compare_p (NE, GET_MODE (temp), ccp_jump)) | |
626 | /* Note swapping the labels gives us not-equal. */ | |
627 | do_jump_by_parts_equality_rtx (temp, if_true_label, if_false_label); | |
628 | else if (GET_MODE (temp) != VOIDmode) | |
6cd6518b | 629 | { |
630 | /* The RTL optimizers prefer comparisons against pseudos. */ | |
631 | if (GET_CODE (temp) == SUBREG) | |
219a7327 | 632 | { |
633 | /* Compare promoted variables in their promoted mode. */ | |
634 | if (SUBREG_PROMOTED_VAR_P (temp) | |
8ad4c111 | 635 | && REG_P (XEXP (temp, 0))) |
219a7327 | 636 | temp = XEXP (temp, 0); |
637 | else | |
638 | temp = copy_to_reg (temp); | |
639 | } | |
6cd6518b | 640 | do_compare_rtx_and_jump (temp, CONST0_RTX (GET_MODE (temp)), |
78a8ed03 | 641 | NE, TYPE_UNSIGNED (TREE_TYPE (exp)), |
6cd6518b | 642 | GET_MODE (temp), NULL_RTX, |
643 | if_false_label, if_true_label); | |
644 | } | |
48fefb59 | 645 | else |
646 | abort (); | |
647 | } | |
648 | ||
649 | if (drop_through_label) | |
650 | { | |
651 | /* If do_jump produces code that might be jumped around, | |
652 | do any stack adjusts from that code, before the place | |
653 | where control merges in. */ | |
654 | do_pending_stack_adjust (); | |
655 | emit_label (drop_through_label); | |
656 | } | |
657 | } | |
658 | \f | |
659 | /* Given a comparison expression EXP for values too wide to be compared | |
660 | with one insn, test the comparison and jump to the appropriate label. | |
661 | The code of EXP is ignored; we always test GT if SWAP is 0, | |
662 | and LT if SWAP is 1. */ | |
663 | ||
664 | static void | |
8ec3a57b | 665 | do_jump_by_parts_greater (tree exp, int swap, rtx if_false_label, |
666 | rtx if_true_label) | |
48fefb59 | 667 | { |
668 | rtx op0 = expand_expr (TREE_OPERAND (exp, swap), NULL_RTX, VOIDmode, 0); | |
669 | rtx op1 = expand_expr (TREE_OPERAND (exp, !swap), NULL_RTX, VOIDmode, 0); | |
670 | enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))); | |
78a8ed03 | 671 | int unsignedp = TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))); |
48fefb59 | 672 | |
78a8ed03 | 673 | do_jump_by_parts_greater_rtx (mode, unsignedp, op0, op1, if_false_label, |
674 | if_true_label); | |
48fefb59 | 675 | } |
676 | ||
677 | /* Compare OP0 with OP1, word at a time, in mode MODE. | |
678 | UNSIGNEDP says to do unsigned comparison. | |
679 | Jump to IF_TRUE_LABEL if OP0 is greater, IF_FALSE_LABEL otherwise. */ | |
680 | ||
681 | void | |
8ec3a57b | 682 | do_jump_by_parts_greater_rtx (enum machine_mode mode, int unsignedp, rtx op0, |
683 | rtx op1, rtx if_false_label, rtx if_true_label) | |
48fefb59 | 684 | { |
685 | int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD); | |
686 | rtx drop_through_label = 0; | |
687 | int i; | |
688 | ||
689 | if (! if_true_label || ! if_false_label) | |
690 | drop_through_label = gen_label_rtx (); | |
691 | if (! if_true_label) | |
692 | if_true_label = drop_through_label; | |
693 | if (! if_false_label) | |
694 | if_false_label = drop_through_label; | |
695 | ||
696 | /* Compare a word at a time, high order first. */ | |
697 | for (i = 0; i < nwords; i++) | |
698 | { | |
699 | rtx op0_word, op1_word; | |
700 | ||
701 | if (WORDS_BIG_ENDIAN) | |
702 | { | |
703 | op0_word = operand_subword_force (op0, i, mode); | |
704 | op1_word = operand_subword_force (op1, i, mode); | |
705 | } | |
706 | else | |
707 | { | |
708 | op0_word = operand_subword_force (op0, nwords - 1 - i, mode); | |
709 | op1_word = operand_subword_force (op1, nwords - 1 - i, mode); | |
710 | } | |
711 | ||
712 | /* All but high-order word must be compared as unsigned. */ | |
713 | do_compare_rtx_and_jump (op0_word, op1_word, GT, | |
714 | (unsignedp || i > 0), word_mode, NULL_RTX, | |
715 | NULL_RTX, if_true_label); | |
716 | ||
717 | /* Consider lower words only if these are equal. */ | |
718 | do_compare_rtx_and_jump (op0_word, op1_word, NE, unsignedp, word_mode, | |
719 | NULL_RTX, NULL_RTX, if_false_label); | |
720 | } | |
721 | ||
722 | if (if_false_label) | |
723 | emit_jump (if_false_label); | |
724 | if (drop_through_label) | |
725 | emit_label (drop_through_label); | |
726 | } | |
727 | ||
728 | /* Given an EQ_EXPR expression EXP for values too wide to be compared | |
729 | with one insn, test the comparison and jump to the appropriate label. */ | |
730 | ||
731 | static void | |
8ec3a57b | 732 | do_jump_by_parts_equality (tree exp, rtx if_false_label, rtx if_true_label) |
48fefb59 | 733 | { |
734 | rtx op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0); | |
735 | rtx op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0); | |
736 | enum machine_mode mode = TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0))); | |
737 | int nwords = (GET_MODE_SIZE (mode) / UNITS_PER_WORD); | |
738 | int i; | |
739 | rtx drop_through_label = 0; | |
740 | ||
741 | if (! if_false_label) | |
742 | drop_through_label = if_false_label = gen_label_rtx (); | |
743 | ||
744 | for (i = 0; i < nwords; i++) | |
745 | do_compare_rtx_and_jump (operand_subword_force (op0, i, mode), | |
746 | operand_subword_force (op1, i, mode), | |
78a8ed03 | 747 | EQ, TYPE_UNSIGNED (TREE_TYPE (exp)), |
48fefb59 | 748 | word_mode, NULL_RTX, if_false_label, NULL_RTX); |
749 | ||
750 | if (if_true_label) | |
751 | emit_jump (if_true_label); | |
752 | if (drop_through_label) | |
753 | emit_label (drop_through_label); | |
754 | } | |
755 | \f | |
756 | /* Jump according to whether OP0 is 0. | |
757 | We assume that OP0 has an integer mode that is too wide | |
758 | for the available compare insns. */ | |
759 | ||
760 | void | |
8ec3a57b | 761 | do_jump_by_parts_equality_rtx (rtx op0, rtx if_false_label, rtx if_true_label) |
48fefb59 | 762 | { |
763 | int nwords = GET_MODE_SIZE (GET_MODE (op0)) / UNITS_PER_WORD; | |
764 | rtx part; | |
765 | int i; | |
766 | rtx drop_through_label = 0; | |
767 | ||
768 | /* The fastest way of doing this comparison on almost any machine is to | |
769 | "or" all the words and compare the result. If all have to be loaded | |
770 | from memory and this is a very wide item, it's possible this may | |
771 | be slower, but that's highly unlikely. */ | |
772 | ||
773 | part = gen_reg_rtx (word_mode); | |
774 | emit_move_insn (part, operand_subword_force (op0, 0, GET_MODE (op0))); | |
775 | for (i = 1; i < nwords && part != 0; i++) | |
776 | part = expand_binop (word_mode, ior_optab, part, | |
777 | operand_subword_force (op0, i, GET_MODE (op0)), | |
778 | part, 1, OPTAB_WIDEN); | |
779 | ||
780 | if (part != 0) | |
781 | { | |
782 | do_compare_rtx_and_jump (part, const0_rtx, EQ, 1, word_mode, | |
783 | NULL_RTX, if_false_label, if_true_label); | |
784 | ||
785 | return; | |
786 | } | |
787 | ||
788 | /* If we couldn't do the "or" simply, do this with a series of compares. */ | |
789 | if (! if_false_label) | |
790 | drop_through_label = if_false_label = gen_label_rtx (); | |
791 | ||
792 | for (i = 0; i < nwords; i++) | |
793 | do_compare_rtx_and_jump (operand_subword_force (op0, i, GET_MODE (op0)), | |
794 | const0_rtx, EQ, 1, word_mode, NULL_RTX, | |
795 | if_false_label, NULL_RTX); | |
796 | ||
797 | if (if_true_label) | |
798 | emit_jump (if_true_label); | |
799 | ||
800 | if (drop_through_label) | |
801 | emit_label (drop_through_label); | |
802 | } | |
803 | \f | |
804 | /* Generate code for a comparison of OP0 and OP1 with rtx code CODE. | |
805 | (including code to compute the values to be compared) | |
806 | and set (CC0) according to the result. | |
807 | The decision as to signed or unsigned comparison must be made by the caller. | |
808 | ||
809 | We force a stack adjustment unless there are currently | |
810 | things pushed on the stack that aren't yet used. | |
811 | ||
812 | If MODE is BLKmode, SIZE is an RTX giving the size of the objects being | |
813 | compared. */ | |
814 | ||
815 | rtx | |
8ec3a57b | 816 | compare_from_rtx (rtx op0, rtx op1, enum rtx_code code, int unsignedp, |
817 | enum machine_mode mode, rtx size) | |
48fefb59 | 818 | { |
48fefb59 | 819 | rtx tem; |
820 | ||
821 | /* If one operand is constant, make it the second one. Only do this | |
822 | if the other operand is not constant as well. */ | |
823 | ||
824 | if (swap_commutative_operands_p (op0, op1)) | |
825 | { | |
826 | tem = op0; | |
827 | op0 = op1; | |
828 | op1 = tem; | |
829 | code = swap_condition (code); | |
830 | } | |
831 | ||
832 | if (flag_force_mem) | |
833 | { | |
834 | op0 = force_not_mem (op0); | |
835 | op1 = force_not_mem (op1); | |
836 | } | |
837 | ||
838 | do_pending_stack_adjust (); | |
839 | ||
ac503e50 | 840 | code = unsignedp ? unsigned_condition (code) : code; |
841 | if (0 != (tem = simplify_relational_operation (code, mode, VOIDmode, | |
842 | op0, op1))) | |
48fefb59 | 843 | { |
ac503e50 | 844 | if (CONSTANT_P (tem)) |
845 | return tem; | |
846 | ||
847 | code = GET_CODE (tem); | |
848 | mode = GET_MODE (tem); | |
849 | op0 = XEXP (tem, 0); | |
850 | op1 = XEXP (tem, 1); | |
851 | unsignedp = (code == GTU || code == LTU || code == GEU || code == LEU); | |
48fefb59 | 852 | } |
48fefb59 | 853 | |
854 | emit_cmp_insn (op0, op1, code, size, mode, unsignedp); | |
855 | ||
856 | #if HAVE_cc0 | |
857 | return gen_rtx_fmt_ee (code, VOIDmode, cc0_rtx, const0_rtx); | |
858 | #else | |
859 | return gen_rtx_fmt_ee (code, VOIDmode, op0, op1); | |
860 | #endif | |
861 | } | |
862 | ||
863 | /* Like do_compare_and_jump but expects the values to compare as two rtx's. | |
864 | The decision as to signed or unsigned comparison must be made by the caller. | |
865 | ||
866 | If MODE is BLKmode, SIZE is an RTX giving the size of the objects being | |
867 | compared. */ | |
868 | ||
869 | void | |
8ec3a57b | 870 | do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp, |
871 | enum machine_mode mode, rtx size, rtx if_false_label, | |
872 | rtx if_true_label) | |
48fefb59 | 873 | { |
48fefb59 | 874 | rtx tem; |
875 | int dummy_true_label = 0; | |
876 | ||
877 | /* Reverse the comparison if that is safe and we want to jump if it is | |
878 | false. */ | |
879 | if (! if_true_label && ! FLOAT_MODE_P (mode)) | |
880 | { | |
881 | if_true_label = if_false_label; | |
882 | if_false_label = 0; | |
883 | code = reverse_condition (code); | |
884 | } | |
885 | ||
886 | /* If one operand is constant, make it the second one. Only do this | |
887 | if the other operand is not constant as well. */ | |
888 | ||
889 | if (swap_commutative_operands_p (op0, op1)) | |
890 | { | |
891 | tem = op0; | |
892 | op0 = op1; | |
893 | op1 = tem; | |
894 | code = swap_condition (code); | |
895 | } | |
896 | ||
897 | if (flag_force_mem) | |
898 | { | |
899 | op0 = force_not_mem (op0); | |
900 | op1 = force_not_mem (op1); | |
901 | } | |
902 | ||
903 | do_pending_stack_adjust (); | |
904 | ||
ac503e50 | 905 | code = unsignedp ? unsigned_condition (code) : code; |
906 | if (0 != (tem = simplify_relational_operation (code, mode, VOIDmode, | |
907 | op0, op1))) | |
48fefb59 | 908 | { |
ac503e50 | 909 | if (CONSTANT_P (tem)) |
910 | { | |
911 | rtx label = (tem == const0_rtx || tem == CONST0_RTX (mode)) | |
912 | ? if_false_label : if_true_label; | |
913 | if (label) | |
914 | emit_jump (label); | |
915 | return; | |
916 | } | |
48fefb59 | 917 | |
ac503e50 | 918 | code = GET_CODE (tem); |
919 | mode = GET_MODE (tem); | |
920 | op0 = XEXP (tem, 0); | |
921 | op1 = XEXP (tem, 1); | |
922 | unsignedp = (code == GTU || code == LTU || code == GEU || code == LEU); | |
48fefb59 | 923 | } |
48fefb59 | 924 | |
925 | if (! if_true_label) | |
926 | { | |
927 | dummy_true_label = 1; | |
928 | if_true_label = gen_label_rtx (); | |
929 | } | |
930 | ||
931 | emit_cmp_and_jump_insns (op0, op1, code, size, mode, unsignedp, | |
932 | if_true_label); | |
933 | ||
934 | if (if_false_label) | |
935 | emit_jump (if_false_label); | |
936 | if (dummy_true_label) | |
937 | emit_label (if_true_label); | |
938 | } | |
939 | ||
940 | /* Generate code for a comparison expression EXP (including code to compute | |
941 | the values to be compared) and a conditional jump to IF_FALSE_LABEL and/or | |
942 | IF_TRUE_LABEL. One of the labels can be NULL_RTX, in which case the | |
943 | generated code will drop through. | |
944 | SIGNED_CODE should be the rtx operation for this comparison for | |
945 | signed data; UNSIGNED_CODE, likewise for use if data is unsigned. | |
946 | ||
947 | We force a stack adjustment unless there are currently | |
948 | things pushed on the stack that aren't yet used. */ | |
949 | ||
950 | static void | |
8ec3a57b | 951 | do_compare_and_jump (tree exp, enum rtx_code signed_code, |
952 | enum rtx_code unsigned_code, rtx if_false_label, | |
953 | rtx if_true_label) | |
48fefb59 | 954 | { |
955 | rtx op0, op1; | |
956 | tree type; | |
957 | enum machine_mode mode; | |
958 | int unsignedp; | |
959 | enum rtx_code code; | |
960 | ||
961 | /* Don't crash if the comparison was erroneous. */ | |
962 | op0 = expand_expr (TREE_OPERAND (exp, 0), NULL_RTX, VOIDmode, 0); | |
963 | if (TREE_CODE (TREE_OPERAND (exp, 0)) == ERROR_MARK) | |
964 | return; | |
965 | ||
966 | op1 = expand_expr (TREE_OPERAND (exp, 1), NULL_RTX, VOIDmode, 0); | |
967 | if (TREE_CODE (TREE_OPERAND (exp, 1)) == ERROR_MARK) | |
968 | return; | |
969 | ||
970 | type = TREE_TYPE (TREE_OPERAND (exp, 0)); | |
971 | mode = TYPE_MODE (type); | |
972 | if (TREE_CODE (TREE_OPERAND (exp, 0)) == INTEGER_CST | |
973 | && (TREE_CODE (TREE_OPERAND (exp, 1)) != INTEGER_CST | |
974 | || (GET_MODE_BITSIZE (mode) | |
975 | > GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, | |
976 | 1))))))) | |
977 | { | |
978 | /* op0 might have been replaced by promoted constant, in which | |
979 | case the type of second argument should be used. */ | |
980 | type = TREE_TYPE (TREE_OPERAND (exp, 1)); | |
981 | mode = TYPE_MODE (type); | |
982 | } | |
78a8ed03 | 983 | unsignedp = TYPE_UNSIGNED (type); |
48fefb59 | 984 | code = unsignedp ? unsigned_code : signed_code; |
985 | ||
986 | #ifdef HAVE_canonicalize_funcptr_for_compare | |
987 | /* If function pointers need to be "canonicalized" before they can | |
988 | be reliably compared, then canonicalize them. */ | |
989 | if (HAVE_canonicalize_funcptr_for_compare | |
990 | && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == POINTER_TYPE | |
991 | && (TREE_CODE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0)))) | |
992 | == FUNCTION_TYPE)) | |
993 | { | |
994 | rtx new_op0 = gen_reg_rtx (mode); | |
995 | ||
996 | emit_insn (gen_canonicalize_funcptr_for_compare (new_op0, op0)); | |
997 | op0 = new_op0; | |
998 | } | |
999 | ||
1000 | if (HAVE_canonicalize_funcptr_for_compare | |
1001 | && TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 1))) == POINTER_TYPE | |
1002 | && (TREE_CODE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 1)))) | |
1003 | == FUNCTION_TYPE)) | |
1004 | { | |
1005 | rtx new_op1 = gen_reg_rtx (mode); | |
1006 | ||
1007 | emit_insn (gen_canonicalize_funcptr_for_compare (new_op1, op1)); | |
1008 | op1 = new_op1; | |
1009 | } | |
1010 | #endif | |
1011 | ||
48fefb59 | 1012 | do_compare_rtx_and_jump (op0, op1, code, unsignedp, mode, |
1013 | ((mode == BLKmode) | |
1014 | ? expr_size (TREE_OPERAND (exp, 0)) : NULL_RTX), | |
1015 | if_false_label, if_true_label); | |
1016 | } | |
d9e19419 | 1017 | |
1018 | #include "gt-dojump.h" |