* extend.texi: Improve documentation of volatile asms.
[official-gcc.git] / gcc / rtlanal.c
blob0525a5de3858758a4ea281dfaa9d56d9a85f40aa
1 /* Analyze RTL for C-Compiler
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
23 #include "config.h"
24 #include "system.h"
25 #include "toplev.h"
26 #include "rtl.h"
27 #include "hard-reg-set.h"
29 static void set_of_1 PARAMS ((rtx, rtx, void *));
30 static void insn_dependent_p_1 PARAMS ((rtx, rtx, void *));
32 /* Forward declarations */
33 static int computed_jump_p_1 PARAMS ((rtx));
35 /* Bit flags that specify the machine subtype we are compiling for.
36 Bits are tested using macros TARGET_... defined in the tm.h file
37 and set by `-m...' switches. Must be defined in rtlanal.c. */
39 int target_flags;
41 /* Return 1 if the value of X is unstable
42 (would be different at a different point in the program).
43 The frame pointer, arg pointer, etc. are considered stable
44 (within one function) and so is anything marked `unchanging'. */
46 int
47 rtx_unstable_p (x)
48 rtx x;
50 register RTX_CODE code = GET_CODE (x);
51 register int i;
52 register const char *fmt;
54 switch (code)
56 case MEM:
57 return ! RTX_UNCHANGING_P (x) || rtx_unstable_p (XEXP (x, 0));
59 case QUEUED:
60 return 1;
62 case CONST:
63 case CONST_INT:
64 case CONST_DOUBLE:
65 case SYMBOL_REF:
66 case LABEL_REF:
67 return 0;
69 case REG:
70 /* As in rtx_varies_p, we have to use the actual rtx, not reg number. */
71 if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
72 /* The arg pointer varies if it is not a fixed register. */
73 || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM])
74 || RTX_UNCHANGING_P (x))
75 return 0;
76 #ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
77 /* ??? When call-clobbered, the value is stable modulo the restore
78 that must happen after a call. This currently screws up local-alloc
79 into believing that the restore is not needed. */
80 if (x == pic_offset_table_rtx)
81 return 0;
82 #endif
83 return 1;
85 case ASM_OPERANDS:
86 if (MEM_VOLATILE_P (x))
87 return 1;
89 /* FALLTHROUGH */
91 default:
92 break;
95 fmt = GET_RTX_FORMAT (code);
96 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
97 if (fmt[i] == 'e')
99 if (rtx_unstable_p (XEXP (x, i)))
100 return 1;
102 else if (fmt[i] == 'E')
104 int j;
105 for (j = 0; j < XVECLEN (x, i); j++)
106 if (rtx_unstable_p (XVECEXP (x, i, j)))
107 return 1;
110 return 0;
113 /* Return 1 if X has a value that can vary even between two
114 executions of the program. 0 means X can be compared reliably
115 against certain constants or near-constants.
116 FOR_ALIAS is nonzero if we are called from alias analysis; if it is
117 zero, we are slightly more conservative.
118 The frame pointer and the arg pointer are considered constant. */
121 rtx_varies_p (x, for_alias)
122 rtx x;
123 int for_alias;
125 register RTX_CODE code = GET_CODE (x);
126 register int i;
127 register const char *fmt;
129 switch (code)
131 case MEM:
132 return ! RTX_UNCHANGING_P (x) || rtx_varies_p (XEXP (x, 0), for_alias);
134 case QUEUED:
135 return 1;
137 case CONST:
138 case CONST_INT:
139 case CONST_DOUBLE:
140 case SYMBOL_REF:
141 case LABEL_REF:
142 return 0;
144 case REG:
145 /* Note that we have to test for the actual rtx used for the frame
146 and arg pointers and not just the register number in case we have
147 eliminated the frame and/or arg pointer and are using it
148 for pseudos. */
149 if (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
150 /* The arg pointer varies if it is not a fixed register. */
151 || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]))
152 return 0;
153 if (x == pic_offset_table_rtx
154 #ifdef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
155 /* ??? When call-clobbered, the value is stable modulo the restore
156 that must happen after a call. This currently screws up
157 local-alloc into believing that the restore is not needed, so we
158 must return 0 only if we are called from alias analysis. */
159 && for_alias
160 #endif
162 return 0;
163 return 1;
165 case LO_SUM:
166 /* The operand 0 of a LO_SUM is considered constant
167 (in fact it is related specifically to operand 1)
168 during alias analysis. */
169 return (! for_alias && rtx_varies_p (XEXP (x, 0), for_alias))
170 || rtx_varies_p (XEXP (x, 1), for_alias);
172 case ASM_OPERANDS:
173 if (MEM_VOLATILE_P (x))
174 return 1;
176 /* FALLTHROUGH */
178 default:
179 break;
182 fmt = GET_RTX_FORMAT (code);
183 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
184 if (fmt[i] == 'e')
186 if (rtx_varies_p (XEXP (x, i), for_alias))
187 return 1;
189 else if (fmt[i] == 'E')
191 int j;
192 for (j = 0; j < XVECLEN (x, i); j++)
193 if (rtx_varies_p (XVECEXP (x, i, j), for_alias))
194 return 1;
197 return 0;
200 /* Return 0 if the use of X as an address in a MEM can cause a trap. */
203 rtx_addr_can_trap_p (x)
204 register rtx x;
206 register enum rtx_code code = GET_CODE (x);
208 switch (code)
210 case SYMBOL_REF:
211 case LABEL_REF:
212 /* SYMBOL_REF is problematic due to the possible presence of
213 a #pragma weak, but to say that loads from symbols can trap is
214 *very* costly. It's not at all clear what's best here. For
215 now, we ignore the impact of #pragma weak. */
216 return 0;
218 case REG:
219 /* As in rtx_varies_p, we have to use the actual rtx, not reg number. */
220 return ! (x == frame_pointer_rtx || x == hard_frame_pointer_rtx
221 || x == stack_pointer_rtx
222 /* The arg pointer varies if it is not a fixed register. */
223 || (x == arg_pointer_rtx && fixed_regs[ARG_POINTER_REGNUM]));
225 case CONST:
226 return rtx_addr_can_trap_p (XEXP (x, 0));
228 case PLUS:
229 /* An address is assumed not to trap if it is an address that can't
230 trap plus a constant integer or it is the pic register plus a
231 constant. */
232 return ! ((! rtx_addr_can_trap_p (XEXP (x, 0))
233 && GET_CODE (XEXP (x, 1)) == CONST_INT)
234 || (XEXP (x, 0) == pic_offset_table_rtx
235 && CONSTANT_P (XEXP (x, 1))));
237 case LO_SUM:
238 return rtx_addr_can_trap_p (XEXP (x, 1));
240 default:
241 break;
244 /* If it isn't one of the case above, it can cause a trap. */
245 return 1;
248 /* Return 1 if X refers to a memory location whose address
249 cannot be compared reliably with constant addresses,
250 or if X refers to a BLKmode memory object.
251 FOR_ALIAS is nonzero if we are called from alias analysis; if it is
252 zero, we are slightly more conservative. */
255 rtx_addr_varies_p (x, for_alias)
256 rtx x;
257 int for_alias;
259 register enum rtx_code code;
260 register int i;
261 register const char *fmt;
263 if (x == 0)
264 return 0;
266 code = GET_CODE (x);
267 if (code == MEM)
268 return GET_MODE (x) == BLKmode || rtx_varies_p (XEXP (x, 0), for_alias);
270 fmt = GET_RTX_FORMAT (code);
271 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
272 if (fmt[i] == 'e')
274 if (rtx_addr_varies_p (XEXP (x, i), for_alias))
275 return 1;
277 else if (fmt[i] == 'E')
279 int j;
280 for (j = 0; j < XVECLEN (x, i); j++)
281 if (rtx_addr_varies_p (XVECEXP (x, i, j), for_alias))
282 return 1;
284 return 0;
287 /* Return the value of the integer term in X, if one is apparent;
288 otherwise return 0.
289 Only obvious integer terms are detected.
290 This is used in cse.c with the `related_value' field.*/
292 HOST_WIDE_INT
293 get_integer_term (x)
294 rtx x;
296 if (GET_CODE (x) == CONST)
297 x = XEXP (x, 0);
299 if (GET_CODE (x) == MINUS
300 && GET_CODE (XEXP (x, 1)) == CONST_INT)
301 return - INTVAL (XEXP (x, 1));
302 if (GET_CODE (x) == PLUS
303 && GET_CODE (XEXP (x, 1)) == CONST_INT)
304 return INTVAL (XEXP (x, 1));
305 return 0;
308 /* If X is a constant, return the value sans apparent integer term;
309 otherwise return 0.
310 Only obvious integer terms are detected. */
313 get_related_value (x)
314 rtx x;
316 if (GET_CODE (x) != CONST)
317 return 0;
318 x = XEXP (x, 0);
319 if (GET_CODE (x) == PLUS
320 && GET_CODE (XEXP (x, 1)) == CONST_INT)
321 return XEXP (x, 0);
322 else if (GET_CODE (x) == MINUS
323 && GET_CODE (XEXP (x, 1)) == CONST_INT)
324 return XEXP (x, 0);
325 return 0;
328 /* Return the number of places FIND appears within X. If COUNT_DEST is
329 zero, we do not count occurrences inside the destination of a SET. */
332 count_occurrences (x, find, count_dest)
333 rtx x, find;
334 int count_dest;
336 int i, j;
337 enum rtx_code code;
338 const char *format_ptr;
339 int count;
341 if (x == find)
342 return 1;
344 code = GET_CODE (x);
346 switch (code)
348 case REG:
349 case CONST_INT:
350 case CONST_DOUBLE:
351 case SYMBOL_REF:
352 case CODE_LABEL:
353 case PC:
354 case CC0:
355 return 0;
357 case MEM:
358 if (GET_CODE (find) == MEM && rtx_equal_p (x, find))
359 return 1;
360 break;
362 case SET:
363 if (SET_DEST (x) == find && ! count_dest)
364 return count_occurrences (SET_SRC (x), find, count_dest);
365 break;
367 default:
368 break;
371 format_ptr = GET_RTX_FORMAT (code);
372 count = 0;
374 for (i = 0; i < GET_RTX_LENGTH (code); i++)
376 switch (*format_ptr++)
378 case 'e':
379 count += count_occurrences (XEXP (x, i), find, count_dest);
380 break;
382 case 'E':
383 for (j = 0; j < XVECLEN (x, i); j++)
384 count += count_occurrences (XVECEXP (x, i, j), find, count_dest);
385 break;
388 return count;
391 /* Nonzero if register REG appears somewhere within IN.
392 Also works if REG is not a register; in this case it checks
393 for a subexpression of IN that is Lisp "equal" to REG. */
396 reg_mentioned_p (reg, in)
397 register rtx reg, in;
399 register const char *fmt;
400 register int i;
401 register enum rtx_code code;
403 if (in == 0)
404 return 0;
406 if (reg == in)
407 return 1;
409 if (GET_CODE (in) == LABEL_REF)
410 return reg == XEXP (in, 0);
412 code = GET_CODE (in);
414 switch (code)
416 /* Compare registers by number. */
417 case REG:
418 return GET_CODE (reg) == REG && REGNO (in) == REGNO (reg);
420 /* These codes have no constituent expressions
421 and are unique. */
422 case SCRATCH:
423 case CC0:
424 case PC:
425 return 0;
427 case CONST_INT:
428 return GET_CODE (reg) == CONST_INT && INTVAL (in) == INTVAL (reg);
430 case CONST_DOUBLE:
431 /* These are kept unique for a given value. */
432 return 0;
434 default:
435 break;
438 if (GET_CODE (reg) == code && rtx_equal_p (reg, in))
439 return 1;
441 fmt = GET_RTX_FORMAT (code);
443 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
445 if (fmt[i] == 'E')
447 register int j;
448 for (j = XVECLEN (in, i) - 1; j >= 0; j--)
449 if (reg_mentioned_p (reg, XVECEXP (in, i, j)))
450 return 1;
452 else if (fmt[i] == 'e'
453 && reg_mentioned_p (reg, XEXP (in, i)))
454 return 1;
456 return 0;
459 /* Return 1 if in between BEG and END, exclusive of BEG and END, there is
460 no CODE_LABEL insn. */
463 no_labels_between_p (beg, end)
464 rtx beg, end;
466 register rtx p;
467 for (p = NEXT_INSN (beg); p != end; p = NEXT_INSN (p))
468 if (GET_CODE (p) == CODE_LABEL)
469 return 0;
470 return 1;
473 /* Return 1 if in between BEG and END, exclusive of BEG and END, there is
474 no JUMP_INSN insn. */
477 no_jumps_between_p (beg, end)
478 rtx beg, end;
480 register rtx p;
481 for (p = NEXT_INSN (beg); p != end; p = NEXT_INSN (p))
482 if (GET_CODE (p) == JUMP_INSN)
483 return 0;
484 return 1;
487 /* Nonzero if register REG is used in an insn between
488 FROM_INSN and TO_INSN (exclusive of those two). */
491 reg_used_between_p (reg, from_insn, to_insn)
492 rtx reg, from_insn, to_insn;
494 register rtx insn;
496 if (from_insn == to_insn)
497 return 0;
499 for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
500 if (INSN_P (insn)
501 && (reg_overlap_mentioned_p (reg, PATTERN (insn))
502 || (GET_CODE (insn) == CALL_INSN
503 && (find_reg_fusage (insn, USE, reg)
504 || find_reg_fusage (insn, CLOBBER, reg)))))
505 return 1;
506 return 0;
509 /* Nonzero if the old value of X, a register, is referenced in BODY. If X
510 is entirely replaced by a new value and the only use is as a SET_DEST,
511 we do not consider it a reference. */
514 reg_referenced_p (x, body)
515 rtx x;
516 rtx body;
518 int i;
520 switch (GET_CODE (body))
522 case SET:
523 if (reg_overlap_mentioned_p (x, SET_SRC (body)))
524 return 1;
526 /* If the destination is anything other than CC0, PC, a REG or a SUBREG
527 of a REG that occupies all of the REG, the insn references X if
528 it is mentioned in the destination. */
529 if (GET_CODE (SET_DEST (body)) != CC0
530 && GET_CODE (SET_DEST (body)) != PC
531 && GET_CODE (SET_DEST (body)) != REG
532 && ! (GET_CODE (SET_DEST (body)) == SUBREG
533 && GET_CODE (SUBREG_REG (SET_DEST (body))) == REG
534 && (((GET_MODE_SIZE (GET_MODE (SUBREG_REG (SET_DEST (body))))
535 + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)
536 == ((GET_MODE_SIZE (GET_MODE (SET_DEST (body)))
537 + (UNITS_PER_WORD - 1)) / UNITS_PER_WORD)))
538 && reg_overlap_mentioned_p (x, SET_DEST (body)))
539 return 1;
540 return 0;
542 case ASM_OPERANDS:
543 for (i = ASM_OPERANDS_INPUT_LENGTH (body) - 1; i >= 0; i--)
544 if (reg_overlap_mentioned_p (x, ASM_OPERANDS_INPUT (body, i)))
545 return 1;
546 return 0;
548 case CALL:
549 case USE:
550 case IF_THEN_ELSE:
551 return reg_overlap_mentioned_p (x, body);
553 case TRAP_IF:
554 return reg_overlap_mentioned_p (x, TRAP_CONDITION (body));
556 case UNSPEC:
557 case UNSPEC_VOLATILE:
558 for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
559 if (reg_overlap_mentioned_p (x, XVECEXP (body, 0, i)))
560 return 1;
561 return 0;
563 case PARALLEL:
564 for (i = XVECLEN (body, 0) - 1; i >= 0; i--)
565 if (reg_referenced_p (x, XVECEXP (body, 0, i)))
566 return 1;
567 return 0;
569 case CLOBBER:
570 if (GET_CODE (XEXP (body, 0)) == MEM)
571 if (reg_overlap_mentioned_p (x, XEXP (XEXP (body, 0), 0)))
572 return 1;
573 return 0;
575 case COND_EXEC:
576 if (reg_overlap_mentioned_p (x, COND_EXEC_TEST (body)))
577 return 1;
578 return reg_referenced_p (x, COND_EXEC_CODE (body));
580 default:
581 return 0;
585 /* Nonzero if register REG is referenced in an insn between
586 FROM_INSN and TO_INSN (exclusive of those two). Sets of REG do
587 not count. */
590 reg_referenced_between_p (reg, from_insn, to_insn)
591 rtx reg, from_insn, to_insn;
593 register rtx insn;
595 if (from_insn == to_insn)
596 return 0;
598 for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
599 if (INSN_P (insn)
600 && (reg_referenced_p (reg, PATTERN (insn))
601 || (GET_CODE (insn) == CALL_INSN
602 && find_reg_fusage (insn, USE, reg))))
603 return 1;
604 return 0;
607 /* Nonzero if register REG is set or clobbered in an insn between
608 FROM_INSN and TO_INSN (exclusive of those two). */
611 reg_set_between_p (reg, from_insn, to_insn)
612 rtx reg, from_insn, to_insn;
614 register rtx insn;
616 if (from_insn == to_insn)
617 return 0;
619 for (insn = NEXT_INSN (from_insn); insn != to_insn; insn = NEXT_INSN (insn))
620 if (INSN_P (insn) && reg_set_p (reg, insn))
621 return 1;
622 return 0;
625 /* Internals of reg_set_between_p. */
627 reg_set_p (reg, insn)
628 rtx reg, insn;
630 rtx body = insn;
632 /* We can be passed an insn or part of one. If we are passed an insn,
633 check if a side-effect of the insn clobbers REG. */
634 if (INSN_P (insn))
636 if (FIND_REG_INC_NOTE (insn, reg)
637 || (GET_CODE (insn) == CALL_INSN
638 /* We'd like to test call_used_regs here, but rtlanal.c can't
639 reference that variable due to its use in genattrtab. So
640 we'll just be more conservative.
642 ??? Unless we could ensure that the CALL_INSN_FUNCTION_USAGE
643 information holds all clobbered registers. */
644 && ((GET_CODE (reg) == REG
645 && REGNO (reg) < FIRST_PSEUDO_REGISTER)
646 || GET_CODE (reg) == MEM
647 || find_reg_fusage (insn, CLOBBER, reg))))
648 return 1;
650 body = PATTERN (insn);
653 return set_of (reg, insn) != NULL_RTX;
656 /* Similar to reg_set_between_p, but check all registers in X. Return 0
657 only if none of them are modified between START and END. Do not
658 consider non-registers one way or the other. */
661 regs_set_between_p (x, start, end)
662 rtx x;
663 rtx start, end;
665 enum rtx_code code = GET_CODE (x);
666 const char *fmt;
667 int i, j;
669 switch (code)
671 case CONST_INT:
672 case CONST_DOUBLE:
673 case CONST:
674 case SYMBOL_REF:
675 case LABEL_REF:
676 case PC:
677 case CC0:
678 return 0;
680 case REG:
681 return reg_set_between_p (x, start, end);
683 default:
684 break;
687 fmt = GET_RTX_FORMAT (code);
688 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
690 if (fmt[i] == 'e' && regs_set_between_p (XEXP (x, i), start, end))
691 return 1;
693 else if (fmt[i] == 'E')
694 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
695 if (regs_set_between_p (XVECEXP (x, i, j), start, end))
696 return 1;
699 return 0;
702 /* Similar to reg_set_between_p, but check all registers in X. Return 0
703 only if none of them are modified between START and END. Return 1 if
704 X contains a MEM; this routine does not perform any memory aliasing. */
707 modified_between_p (x, start, end)
708 rtx x;
709 rtx start, end;
711 enum rtx_code code = GET_CODE (x);
712 const char *fmt;
713 int i, j;
715 switch (code)
717 case CONST_INT:
718 case CONST_DOUBLE:
719 case CONST:
720 case SYMBOL_REF:
721 case LABEL_REF:
722 return 0;
724 case PC:
725 case CC0:
726 return 1;
728 case MEM:
729 /* If the memory is not constant, assume it is modified. If it is
730 constant, we still have to check the address. */
731 if (! RTX_UNCHANGING_P (x))
732 return 1;
733 break;
735 case REG:
736 return reg_set_between_p (x, start, end);
738 default:
739 break;
742 fmt = GET_RTX_FORMAT (code);
743 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
745 if (fmt[i] == 'e' && modified_between_p (XEXP (x, i), start, end))
746 return 1;
748 else if (fmt[i] == 'E')
749 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
750 if (modified_between_p (XVECEXP (x, i, j), start, end))
751 return 1;
754 return 0;
757 /* Similar to reg_set_p, but check all registers in X. Return 0 only if none
758 of them are modified in INSN. Return 1 if X contains a MEM; this routine
759 does not perform any memory aliasing. */
762 modified_in_p (x, insn)
763 rtx x;
764 rtx insn;
766 enum rtx_code code = GET_CODE (x);
767 const char *fmt;
768 int i, j;
770 switch (code)
772 case CONST_INT:
773 case CONST_DOUBLE:
774 case CONST:
775 case SYMBOL_REF:
776 case LABEL_REF:
777 return 0;
779 case PC:
780 case CC0:
781 return 1;
783 case MEM:
784 /* If the memory is not constant, assume it is modified. If it is
785 constant, we still have to check the address. */
786 if (! RTX_UNCHANGING_P (x))
787 return 1;
788 break;
790 case REG:
791 return reg_set_p (x, insn);
793 default:
794 break;
797 fmt = GET_RTX_FORMAT (code);
798 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
800 if (fmt[i] == 'e' && modified_in_p (XEXP (x, i), insn))
801 return 1;
803 else if (fmt[i] == 'E')
804 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
805 if (modified_in_p (XVECEXP (x, i, j), insn))
806 return 1;
809 return 0;
812 /* Return true if anything in insn X is (anti,output,true) dependent on
813 anything in insn Y. */
816 insn_dependent_p (x, y)
817 rtx x, y;
819 rtx tmp;
821 if (! INSN_P (x) || ! INSN_P (y))
822 abort ();
824 tmp = PATTERN (y);
825 note_stores (PATTERN (x), insn_dependent_p_1, &tmp);
826 if (tmp == NULL_RTX)
827 return 1;
829 tmp = PATTERN (x);
830 note_stores (PATTERN (y), insn_dependent_p_1, &tmp);
831 if (tmp == NULL_RTX)
832 return 1;
834 return 0;
837 /* A helper routine for insn_dependent_p called through note_stores. */
839 static void
840 insn_dependent_p_1 (x, pat, data)
841 rtx x;
842 rtx pat ATTRIBUTE_UNUSED;
843 void *data;
845 rtx * pinsn = (rtx *) data;
847 if (*pinsn && reg_mentioned_p (x, *pinsn))
848 *pinsn = NULL_RTX;
851 /* Helper function for set_of. */
852 struct set_of_data
854 rtx found;
855 rtx pat;
858 static void
859 set_of_1 (x, pat, data1)
860 rtx x;
861 rtx pat;
862 void *data1;
864 struct set_of_data *data = (struct set_of_data *) (data1);
865 if (rtx_equal_p (x, data->pat)
866 || (GET_CODE (x) != MEM && reg_overlap_mentioned_p (data->pat, x)))
867 data->found = pat;
870 /* Give an INSN, return a SET or CLOBBER expression that does modify PAT
871 (eighter directly or via STRICT_LOW_PART and similar modifiers). */
873 set_of (pat, insn)
874 rtx pat, insn;
876 struct set_of_data data;
877 data.found = NULL_RTX;
878 data.pat = pat;
879 note_stores (INSN_P (insn) ? PATTERN (insn) : insn, set_of_1, &data);
880 return data.found;
883 /* Given an INSN, return a SET expression if this insn has only a single SET.
884 It may also have CLOBBERs, USEs, or SET whose output
885 will not be used, which we ignore. */
888 single_set_2 (insn, pat)
889 rtx insn, pat;
891 rtx set = NULL;
892 int set_verified = 1;
893 int i;
895 if (GET_CODE (pat) == PARALLEL)
897 for (i = 0; i < XVECLEN (pat, 0); i++)
899 rtx sub = XVECEXP (pat, 0, i);
900 switch (GET_CODE (sub))
902 case USE:
903 case CLOBBER:
904 break;
906 case SET:
907 /* We can consider insns having multiple sets, where all
908 but one are dead as single set insns. In common case
909 only single set is present in the pattern so we want
910 to avoid checking for REG_UNUSED notes unless neccesary.
912 When we reach set first time, we just expect this is
913 the single set we are looking for and only when more
914 sets are found in the insn, we check them. */
915 if (!set_verified)
917 if (find_reg_note (insn, REG_UNUSED, SET_DEST (set))
918 && !side_effects_p (set))
919 set = NULL;
920 else
921 set_verified = 1;
923 if (!set)
924 set = sub, set_verified = 0;
925 else if (!find_reg_note (insn, REG_UNUSED, SET_DEST (sub))
926 || side_effects_p (sub))
927 return NULL_RTX;
928 break;
930 default:
931 return NULL_RTX;
935 return set;
938 /* Given an INSN, return nonzero if it has more than one SET, else return
939 zero. */
942 multiple_sets (insn)
943 rtx insn;
945 int found;
946 int i;
948 /* INSN must be an insn. */
949 if (! INSN_P (insn))
950 return 0;
952 /* Only a PARALLEL can have multiple SETs. */
953 if (GET_CODE (PATTERN (insn)) == PARALLEL)
955 for (i = 0, found = 0; i < XVECLEN (PATTERN (insn), 0); i++)
956 if (GET_CODE (XVECEXP (PATTERN (insn), 0, i)) == SET)
958 /* If we have already found a SET, then return now. */
959 if (found)
960 return 1;
961 else
962 found = 1;
966 /* Either zero or one SET. */
967 return 0;
970 /* Return the last thing that X was assigned from before *PINSN. If VALID_TO
971 is not NULL_RTX then verify that the object is not modified up to VALID_TO.
972 If the object was modified, if we hit a partial assignment to X, or hit a
973 CODE_LABEL first, return X. If we found an assignment, update *PINSN to
974 point to it. ALLOW_HWREG is set to 1 if hardware registers are allowed to
975 be the src. */
978 find_last_value (x, pinsn, valid_to, allow_hwreg)
979 rtx x;
980 rtx *pinsn;
981 rtx valid_to;
982 int allow_hwreg;
984 rtx p;
986 for (p = PREV_INSN (*pinsn); p && GET_CODE (p) != CODE_LABEL;
987 p = PREV_INSN (p))
988 if (INSN_P (p))
990 rtx set = single_set (p);
991 rtx note = find_reg_note (p, REG_EQUAL, NULL_RTX);
993 if (set && rtx_equal_p (x, SET_DEST (set)))
995 rtx src = SET_SRC (set);
997 if (note && GET_CODE (XEXP (note, 0)) != EXPR_LIST)
998 src = XEXP (note, 0);
1000 if ((valid_to == NULL_RTX
1001 || ! modified_between_p (src, PREV_INSN (p), valid_to))
1002 /* Reject hard registers because we don't usually want
1003 to use them; we'd rather use a pseudo. */
1004 && (! (GET_CODE (src) == REG
1005 && REGNO (src) < FIRST_PSEUDO_REGISTER) || allow_hwreg))
1007 *pinsn = p;
1008 return src;
1012 /* If set in non-simple way, we don't have a value. */
1013 if (reg_set_p (x, p))
1014 break;
1017 return x;
1020 /* Return nonzero if register in range [REGNO, ENDREGNO)
1021 appears either explicitly or implicitly in X
1022 other than being stored into.
1024 References contained within the substructure at LOC do not count.
1025 LOC may be zero, meaning don't ignore anything. */
1028 refers_to_regno_p (regno, endregno, x, loc)
1029 unsigned int regno, endregno;
1030 rtx x;
1031 rtx *loc;
1033 int i;
1034 unsigned int x_regno;
1035 RTX_CODE code;
1036 const char *fmt;
1038 repeat:
1039 /* The contents of a REG_NONNEG note is always zero, so we must come here
1040 upon repeat in case the last REG_NOTE is a REG_NONNEG note. */
1041 if (x == 0)
1042 return 0;
1044 code = GET_CODE (x);
1046 switch (code)
1048 case REG:
1049 x_regno = REGNO (x);
1051 /* If we modifying the stack, frame, or argument pointer, it will
1052 clobber a virtual register. In fact, we could be more precise,
1053 but it isn't worth it. */
1054 if ((x_regno == STACK_POINTER_REGNUM
1055 #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
1056 || x_regno == ARG_POINTER_REGNUM
1057 #endif
1058 || x_regno == FRAME_POINTER_REGNUM)
1059 && regno >= FIRST_VIRTUAL_REGISTER && regno <= LAST_VIRTUAL_REGISTER)
1060 return 1;
1062 return (endregno > x_regno
1063 && regno < x_regno + (x_regno < FIRST_PSEUDO_REGISTER
1064 ? HARD_REGNO_NREGS (x_regno, GET_MODE (x))
1065 : 1));
1067 case SUBREG:
1068 /* If this is a SUBREG of a hard reg, we can see exactly which
1069 registers are being modified. Otherwise, handle normally. */
1070 if (GET_CODE (SUBREG_REG (x)) == REG
1071 && REGNO (SUBREG_REG (x)) < FIRST_PSEUDO_REGISTER)
1073 unsigned int inner_regno = REGNO (SUBREG_REG (x)) + SUBREG_WORD (x);
1074 unsigned int inner_endregno
1075 = inner_regno + (inner_regno < FIRST_PSEUDO_REGISTER
1076 ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
1078 return endregno > inner_regno && regno < inner_endregno;
1080 break;
1082 case CLOBBER:
1083 case SET:
1084 if (&SET_DEST (x) != loc
1085 /* Note setting a SUBREG counts as referring to the REG it is in for
1086 a pseudo but not for hard registers since we can
1087 treat each word individually. */
1088 && ((GET_CODE (SET_DEST (x)) == SUBREG
1089 && loc != &SUBREG_REG (SET_DEST (x))
1090 && GET_CODE (SUBREG_REG (SET_DEST (x))) == REG
1091 && REGNO (SUBREG_REG (SET_DEST (x))) >= FIRST_PSEUDO_REGISTER
1092 && refers_to_regno_p (regno, endregno,
1093 SUBREG_REG (SET_DEST (x)), loc))
1094 || (GET_CODE (SET_DEST (x)) != REG
1095 && refers_to_regno_p (regno, endregno, SET_DEST (x), loc))))
1096 return 1;
1098 if (code == CLOBBER || loc == &SET_SRC (x))
1099 return 0;
1100 x = SET_SRC (x);
1101 goto repeat;
1103 default:
1104 break;
1107 /* X does not match, so try its subexpressions. */
1109 fmt = GET_RTX_FORMAT (code);
1110 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1112 if (fmt[i] == 'e' && loc != &XEXP (x, i))
1114 if (i == 0)
1116 x = XEXP (x, 0);
1117 goto repeat;
1119 else
1120 if (refers_to_regno_p (regno, endregno, XEXP (x, i), loc))
1121 return 1;
1123 else if (fmt[i] == 'E')
1125 register int j;
1126 for (j = XVECLEN (x, i) - 1; j >=0; j--)
1127 if (loc != &XVECEXP (x, i, j)
1128 && refers_to_regno_p (regno, endregno, XVECEXP (x, i, j), loc))
1129 return 1;
1132 return 0;
1135 /* Nonzero if modifying X will affect IN. If X is a register or a SUBREG,
1136 we check if any register number in X conflicts with the relevant register
1137 numbers. If X is a constant, return 0. If X is a MEM, return 1 iff IN
1138 contains a MEM (we don't bother checking for memory addresses that can't
1139 conflict because we expect this to be a rare case. */
1142 reg_overlap_mentioned_p (x, in)
1143 rtx x, in;
1145 unsigned int regno, endregno;
1147 /* Overly conservative. */
1148 if (GET_CODE (x) == STRICT_LOW_PART)
1149 x = XEXP (x, 0);
1151 /* If either argument is a constant, then modifying X can not affect IN. */
1152 if (CONSTANT_P (x) || CONSTANT_P (in))
1153 return 0;
1155 switch (GET_CODE (x))
1157 case SUBREG:
1158 regno = REGNO (SUBREG_REG (x));
1159 if (regno < FIRST_PSEUDO_REGISTER)
1160 regno += SUBREG_WORD (x);
1161 goto do_reg;
1163 case REG:
1164 regno = REGNO (x);
1165 do_reg:
1166 endregno = regno + (regno < FIRST_PSEUDO_REGISTER
1167 ? HARD_REGNO_NREGS (regno, GET_MODE (x)) : 1);
1168 return refers_to_regno_p (regno, endregno, in, NULL_PTR);
1170 case MEM:
1172 const char *fmt;
1173 int i;
1175 if (GET_CODE (in) == MEM)
1176 return 1;
1178 fmt = GET_RTX_FORMAT (GET_CODE (in));
1179 for (i = GET_RTX_LENGTH (GET_CODE (in)) - 1; i >= 0; i--)
1180 if (fmt[i] == 'e' && reg_overlap_mentioned_p (x, XEXP (in, i)))
1181 return 1;
1183 return 0;
1186 case SCRATCH:
1187 case PC:
1188 case CC0:
1189 return reg_mentioned_p (x, in);
1191 case PARALLEL:
1193 int i;
1195 /* If any register in here refers to it we return true. */
1196 for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
1197 if (XEXP (XVECEXP (x, 0, i), 0) != 0
1198 && reg_overlap_mentioned_p (XEXP (XVECEXP (x, 0, i), 0), in))
1199 return 1;
1200 return 0;
1203 default:
1204 break;
1207 abort ();
1210 /* Return the last value to which REG was set prior to INSN. If we can't
1211 find it easily, return 0.
1213 We only return a REG, SUBREG, or constant because it is too hard to
1214 check if a MEM remains unchanged. */
1217 reg_set_last (x, insn)
1218 rtx x;
1219 rtx insn;
1221 rtx orig_insn = insn;
1223 /* Scan backwards until reg_set_last_1 changed one of the above flags.
1224 Stop when we reach a label or X is a hard reg and we reach a
1225 CALL_INSN (if reg_set_last_last_regno is a hard reg).
1227 If we find a set of X, ensure that its SET_SRC remains unchanged. */
1229 /* We compare with <= here, because reg_set_last_last_regno
1230 is actually the number of the first reg *not* in X. */
1231 for (;
1232 insn && GET_CODE (insn) != CODE_LABEL
1233 && ! (GET_CODE (insn) == CALL_INSN
1234 && REGNO (x) <= FIRST_PSEUDO_REGISTER);
1235 insn = PREV_INSN (insn))
1236 if (INSN_P (insn))
1238 rtx set = set_of (x, insn);
1239 /* OK, this function modify our register. See if we understand it. */
1240 if (set)
1242 rtx last_value;
1243 if (GET_CODE (set) != SET || SET_DEST (set) != x)
1244 return 0;
1245 last_value = SET_SRC (x);
1246 if (CONSTANT_P (last_value)
1247 || ((GET_CODE (last_value) == REG
1248 || GET_CODE (last_value) == SUBREG)
1249 && ! reg_set_between_p (last_value,
1250 insn, orig_insn)))
1251 return last_value;
1252 else
1253 return 0;
1257 return 0;
1260 /* Call FUN on each register or MEM that is stored into or clobbered by X.
1261 (X would be the pattern of an insn).
1262 FUN receives two arguments:
1263 the REG, MEM, CC0 or PC being stored in or clobbered,
1264 the SET or CLOBBER rtx that does the store.
1266 If the item being stored in or clobbered is a SUBREG of a hard register,
1267 the SUBREG will be passed. */
1269 void
1270 note_stores (x, fun, data)
1271 register rtx x;
1272 void (*fun) PARAMS ((rtx, rtx, void *));
1273 void *data;
1275 int i;
1277 if (GET_CODE (x) == COND_EXEC)
1278 x = COND_EXEC_CODE (x);
1280 if (GET_CODE (x) == SET || GET_CODE (x) == CLOBBER)
1282 register rtx dest = SET_DEST (x);
1284 while ((GET_CODE (dest) == SUBREG
1285 && (GET_CODE (SUBREG_REG (dest)) != REG
1286 || REGNO (SUBREG_REG (dest)) >= FIRST_PSEUDO_REGISTER))
1287 || GET_CODE (dest) == ZERO_EXTRACT
1288 || GET_CODE (dest) == SIGN_EXTRACT
1289 || GET_CODE (dest) == STRICT_LOW_PART)
1290 dest = XEXP (dest, 0);
1292 /* If we have a PARALLEL, SET_DEST is a list of EXPR_LIST expressions,
1293 each of whose first operand is a register. We can't know what
1294 precisely is being set in these cases, so make up a CLOBBER to pass
1295 to the function. */
1296 if (GET_CODE (dest) == PARALLEL)
1298 for (i = XVECLEN (dest, 0) - 1; i >= 0; i--)
1299 if (XEXP (XVECEXP (dest, 0, i), 0) != 0)
1300 (*fun) (XEXP (XVECEXP (dest, 0, i), 0),
1301 gen_rtx_CLOBBER (VOIDmode,
1302 XEXP (XVECEXP (dest, 0, i), 0)),
1303 data);
1305 else
1306 (*fun) (dest, x, data);
1309 else if (GET_CODE (x) == PARALLEL)
1310 for (i = XVECLEN (x, 0) - 1; i >= 0; i--)
1311 note_stores (XVECEXP (x, 0, i), fun, data);
1314 /* Return nonzero if X's old contents don't survive after INSN.
1315 This will be true if X is (cc0) or if X is a register and
1316 X dies in INSN or because INSN entirely sets X.
1318 "Entirely set" means set directly and not through a SUBREG,
1319 ZERO_EXTRACT or SIGN_EXTRACT, so no trace of the old contents remains.
1320 Likewise, REG_INC does not count.
1322 REG may be a hard or pseudo reg. Renumbering is not taken into account,
1323 but for this use that makes no difference, since regs don't overlap
1324 during their lifetimes. Therefore, this function may be used
1325 at any time after deaths have been computed (in flow.c).
1327 If REG is a hard reg that occupies multiple machine registers, this
1328 function will only return 1 if each of those registers will be replaced
1329 by INSN. */
1332 dead_or_set_p (insn, x)
1333 rtx insn;
1334 rtx x;
1336 unsigned int regno, last_regno;
1337 unsigned int i;
1339 /* Can't use cc0_rtx below since this file is used by genattrtab.c. */
1340 if (GET_CODE (x) == CC0)
1341 return 1;
1343 if (GET_CODE (x) != REG)
1344 abort ();
1346 regno = REGNO (x);
1347 last_regno = (regno >= FIRST_PSEUDO_REGISTER ? regno
1348 : regno + HARD_REGNO_NREGS (regno, GET_MODE (x)) - 1);
1350 for (i = regno; i <= last_regno; i++)
1351 if (! dead_or_set_regno_p (insn, i))
1352 return 0;
1354 return 1;
1357 /* Utility function for dead_or_set_p to check an individual register. Also
1358 called from flow.c. */
1361 dead_or_set_regno_p (insn, test_regno)
1362 rtx insn;
1363 unsigned int test_regno;
1365 unsigned int regno, endregno;
1366 rtx pattern;
1368 /* See if there is a death note for something that includes TEST_REGNO. */
1369 if (find_regno_note (insn, REG_DEAD, test_regno))
1370 return 1;
1372 if (GET_CODE (insn) == CALL_INSN
1373 && find_regno_fusage (insn, CLOBBER, test_regno))
1374 return 1;
1376 pattern = PATTERN (insn);
1378 if (GET_CODE (pattern) == COND_EXEC)
1379 pattern = COND_EXEC_CODE (pattern);
1381 if (GET_CODE (pattern) == SET)
1383 rtx dest = SET_DEST (PATTERN (insn));
1385 /* A value is totally replaced if it is the destination or the
1386 destination is a SUBREG of REGNO that does not change the number of
1387 words in it. */
1388 if (GET_CODE (dest) == SUBREG
1389 && (((GET_MODE_SIZE (GET_MODE (dest))
1390 + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1391 == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))
1392 + UNITS_PER_WORD - 1) / UNITS_PER_WORD)))
1393 dest = SUBREG_REG (dest);
1395 if (GET_CODE (dest) != REG)
1396 return 0;
1398 regno = REGNO (dest);
1399 endregno = (regno >= FIRST_PSEUDO_REGISTER ? regno + 1
1400 : regno + HARD_REGNO_NREGS (regno, GET_MODE (dest)));
1402 return (test_regno >= regno && test_regno < endregno);
1404 else if (GET_CODE (pattern) == PARALLEL)
1406 register int i;
1408 for (i = XVECLEN (pattern, 0) - 1; i >= 0; i--)
1410 rtx body = XVECEXP (pattern, 0, i);
1412 if (GET_CODE (body) == COND_EXEC)
1413 body = COND_EXEC_CODE (body);
1415 if (GET_CODE (body) == SET || GET_CODE (body) == CLOBBER)
1417 rtx dest = SET_DEST (body);
1419 if (GET_CODE (dest) == SUBREG
1420 && (((GET_MODE_SIZE (GET_MODE (dest))
1421 + UNITS_PER_WORD - 1) / UNITS_PER_WORD)
1422 == ((GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest)))
1423 + UNITS_PER_WORD - 1) / UNITS_PER_WORD)))
1424 dest = SUBREG_REG (dest);
1426 if (GET_CODE (dest) != REG)
1427 continue;
1429 regno = REGNO (dest);
1430 endregno = (regno >= FIRST_PSEUDO_REGISTER ? regno + 1
1431 : regno + HARD_REGNO_NREGS (regno, GET_MODE (dest)));
1433 if (test_regno >= regno && test_regno < endregno)
1434 return 1;
1439 return 0;
1442 /* Return the reg-note of kind KIND in insn INSN, if there is one.
1443 If DATUM is nonzero, look for one whose datum is DATUM. */
1446 find_reg_note (insn, kind, datum)
1447 rtx insn;
1448 enum reg_note kind;
1449 rtx datum;
1451 register rtx link;
1453 /* Ignore anything that is not an INSN, JUMP_INSN or CALL_INSN. */
1454 if (! INSN_P (insn))
1455 return 0;
1457 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
1458 if (REG_NOTE_KIND (link) == kind
1459 && (datum == 0 || datum == XEXP (link, 0)))
1460 return link;
1461 return 0;
1464 /* Return the reg-note of kind KIND in insn INSN which applies to register
1465 number REGNO, if any. Return 0 if there is no such reg-note. Note that
1466 the REGNO of this NOTE need not be REGNO if REGNO is a hard register;
1467 it might be the case that the note overlaps REGNO. */
1470 find_regno_note (insn, kind, regno)
1471 rtx insn;
1472 enum reg_note kind;
1473 unsigned int regno;
1475 register rtx link;
1477 /* Ignore anything that is not an INSN, JUMP_INSN or CALL_INSN. */
1478 if (! INSN_P (insn))
1479 return 0;
1481 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
1482 if (REG_NOTE_KIND (link) == kind
1483 /* Verify that it is a register, so that scratch and MEM won't cause a
1484 problem here. */
1485 && GET_CODE (XEXP (link, 0)) == REG
1486 && REGNO (XEXP (link, 0)) <= regno
1487 && ((REGNO (XEXP (link, 0))
1488 + (REGNO (XEXP (link, 0)) >= FIRST_PSEUDO_REGISTER ? 1
1489 : HARD_REGNO_NREGS (REGNO (XEXP (link, 0)),
1490 GET_MODE (XEXP (link, 0)))))
1491 > regno))
1492 return link;
1493 return 0;
1496 /* Return true if DATUM, or any overlap of DATUM, of kind CODE is found
1497 in the CALL_INSN_FUNCTION_USAGE information of INSN. */
1500 find_reg_fusage (insn, code, datum)
1501 rtx insn;
1502 enum rtx_code code;
1503 rtx datum;
1505 /* If it's not a CALL_INSN, it can't possibly have a
1506 CALL_INSN_FUNCTION_USAGE field, so don't bother checking. */
1507 if (GET_CODE (insn) != CALL_INSN)
1508 return 0;
1510 if (! datum)
1511 abort();
1513 if (GET_CODE (datum) != REG)
1515 register rtx link;
1517 for (link = CALL_INSN_FUNCTION_USAGE (insn);
1518 link;
1519 link = XEXP (link, 1))
1520 if (GET_CODE (XEXP (link, 0)) == code
1521 && rtx_equal_p (datum, SET_DEST (XEXP (link, 0))))
1522 return 1;
1524 else
1526 unsigned int regno = REGNO (datum);
1528 /* CALL_INSN_FUNCTION_USAGE information cannot contain references
1529 to pseudo registers, so don't bother checking. */
1531 if (regno < FIRST_PSEUDO_REGISTER)
1533 unsigned int end_regno
1534 = regno + HARD_REGNO_NREGS (regno, GET_MODE (datum));
1535 unsigned int i;
1537 for (i = regno; i < end_regno; i++)
1538 if (find_regno_fusage (insn, code, i))
1539 return 1;
1543 return 0;
1546 /* Return true if REGNO, or any overlap of REGNO, of kind CODE is found
1547 in the CALL_INSN_FUNCTION_USAGE information of INSN. */
1550 find_regno_fusage (insn, code, regno)
1551 rtx insn;
1552 enum rtx_code code;
1553 unsigned int regno;
1555 register rtx link;
1557 /* CALL_INSN_FUNCTION_USAGE information cannot contain references
1558 to pseudo registers, so don't bother checking. */
1560 if (regno >= FIRST_PSEUDO_REGISTER
1561 || GET_CODE (insn) != CALL_INSN )
1562 return 0;
1564 for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1))
1566 unsigned int regnote;
1567 rtx op, reg;
1569 if (GET_CODE (op = XEXP (link, 0)) == code
1570 && GET_CODE (reg = XEXP (op, 0)) == REG
1571 && (regnote = REGNO (reg)) <= regno
1572 && regnote + HARD_REGNO_NREGS (regnote, GET_MODE (reg)) > regno)
1573 return 1;
1576 return 0;
1579 /* Remove register note NOTE from the REG_NOTES of INSN. */
1581 void
1582 remove_note (insn, note)
1583 register rtx insn;
1584 register rtx note;
1586 register rtx link;
1588 if (note == NULL_RTX)
1589 return;
1591 if (REG_NOTES (insn) == note)
1593 REG_NOTES (insn) = XEXP (note, 1);
1594 return;
1597 for (link = REG_NOTES (insn); link; link = XEXP (link, 1))
1598 if (XEXP (link, 1) == note)
1600 XEXP (link, 1) = XEXP (note, 1);
1601 return;
1604 abort ();
1607 /* Search LISTP (an EXPR_LIST) for an entry whose first operand is NODE and
1608 remove that entry from the list if it is found.
1610 A simple equality test is used to determine if NODE matches. */
1612 void
1613 remove_node_from_expr_list (node, listp)
1614 rtx node;
1615 rtx *listp;
1617 rtx temp = *listp;
1618 rtx prev = NULL_RTX;
1620 while (temp)
1622 if (node == XEXP (temp, 0))
1624 /* Splice the node out of the list. */
1625 if (prev)
1626 XEXP (prev, 1) = XEXP (temp, 1);
1627 else
1628 *listp = XEXP (temp, 1);
1630 return;
1633 prev = temp;
1634 temp = XEXP (temp, 1);
1638 /* Nonzero if X contains any volatile instructions. These are instructions
1639 which may cause unpredictable machine state instructions, and thus no
1640 instructions should be moved or combined across them. This includes
1641 only volatile asms and UNSPEC_VOLATILE instructions. */
1644 volatile_insn_p (x)
1645 rtx x;
1647 register RTX_CODE code;
1649 code = GET_CODE (x);
1650 switch (code)
1652 case LABEL_REF:
1653 case SYMBOL_REF:
1654 case CONST_INT:
1655 case CONST:
1656 case CONST_DOUBLE:
1657 case CC0:
1658 case PC:
1659 case REG:
1660 case SCRATCH:
1661 case CLOBBER:
1662 case ASM_INPUT:
1663 case ADDR_VEC:
1664 case ADDR_DIFF_VEC:
1665 case CALL:
1666 case MEM:
1667 return 0;
1669 case UNSPEC_VOLATILE:
1670 /* case TRAP_IF: This isn't clear yet. */
1671 return 1;
1673 case ASM_OPERANDS:
1674 if (MEM_VOLATILE_P (x))
1675 return 1;
1677 default:
1678 break;
1681 /* Recursively scan the operands of this expression. */
1684 register const char *fmt = GET_RTX_FORMAT (code);
1685 register int i;
1687 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1689 if (fmt[i] == 'e')
1691 if (volatile_insn_p (XEXP (x, i)))
1692 return 1;
1694 else if (fmt[i] == 'E')
1696 register int j;
1697 for (j = 0; j < XVECLEN (x, i); j++)
1698 if (volatile_insn_p (XVECEXP (x, i, j)))
1699 return 1;
1703 return 0;
1706 /* Nonzero if X contains any volatile memory references
1707 UNSPEC_VOLATILE operations or volatile ASM_OPERANDS expressions. */
1710 volatile_refs_p (x)
1711 rtx x;
1713 register RTX_CODE code;
1715 code = GET_CODE (x);
1716 switch (code)
1718 case LABEL_REF:
1719 case SYMBOL_REF:
1720 case CONST_INT:
1721 case CONST:
1722 case CONST_DOUBLE:
1723 case CC0:
1724 case PC:
1725 case REG:
1726 case SCRATCH:
1727 case CLOBBER:
1728 case ASM_INPUT:
1729 case ADDR_VEC:
1730 case ADDR_DIFF_VEC:
1731 return 0;
1733 case CALL:
1734 case UNSPEC_VOLATILE:
1735 /* case TRAP_IF: This isn't clear yet. */
1736 return 1;
1738 case MEM:
1739 case ASM_OPERANDS:
1740 if (MEM_VOLATILE_P (x))
1741 return 1;
1743 default:
1744 break;
1747 /* Recursively scan the operands of this expression. */
1750 register const char *fmt = GET_RTX_FORMAT (code);
1751 register int i;
1753 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1755 if (fmt[i] == 'e')
1757 if (volatile_refs_p (XEXP (x, i)))
1758 return 1;
1760 else if (fmt[i] == 'E')
1762 register int j;
1763 for (j = 0; j < XVECLEN (x, i); j++)
1764 if (volatile_refs_p (XVECEXP (x, i, j)))
1765 return 1;
1769 return 0;
1772 /* Similar to above, except that it also rejects register pre- and post-
1773 incrementing. */
1776 side_effects_p (x)
1777 rtx x;
1779 register RTX_CODE code;
1781 code = GET_CODE (x);
1782 switch (code)
1784 case LABEL_REF:
1785 case SYMBOL_REF:
1786 case CONST_INT:
1787 case CONST:
1788 case CONST_DOUBLE:
1789 case CC0:
1790 case PC:
1791 case REG:
1792 case SCRATCH:
1793 case ASM_INPUT:
1794 case ADDR_VEC:
1795 case ADDR_DIFF_VEC:
1796 return 0;
1798 case CLOBBER:
1799 /* Reject CLOBBER with a non-VOID mode. These are made by combine.c
1800 when some combination can't be done. If we see one, don't think
1801 that we can simplify the expression. */
1802 return (GET_MODE (x) != VOIDmode);
1804 case PRE_INC:
1805 case PRE_DEC:
1806 case POST_INC:
1807 case POST_DEC:
1808 case PRE_MODIFY:
1809 case POST_MODIFY:
1810 case CALL:
1811 case UNSPEC_VOLATILE:
1812 /* case TRAP_IF: This isn't clear yet. */
1813 return 1;
1815 case MEM:
1816 case ASM_OPERANDS:
1817 if (MEM_VOLATILE_P (x))
1818 return 1;
1820 default:
1821 break;
1824 /* Recursively scan the operands of this expression. */
1827 register const char *fmt = GET_RTX_FORMAT (code);
1828 register int i;
1830 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1832 if (fmt[i] == 'e')
1834 if (side_effects_p (XEXP (x, i)))
1835 return 1;
1837 else if (fmt[i] == 'E')
1839 register int j;
1840 for (j = 0; j < XVECLEN (x, i); j++)
1841 if (side_effects_p (XVECEXP (x, i, j)))
1842 return 1;
1846 return 0;
1849 /* Return nonzero if evaluating rtx X might cause a trap. */
1852 may_trap_p (x)
1853 rtx x;
1855 int i;
1856 enum rtx_code code;
1857 const char *fmt;
1859 if (x == 0)
1860 return 0;
1861 code = GET_CODE (x);
1862 switch (code)
1864 /* Handle these cases quickly. */
1865 case CONST_INT:
1866 case CONST_DOUBLE:
1867 case SYMBOL_REF:
1868 case LABEL_REF:
1869 case CONST:
1870 case PC:
1871 case CC0:
1872 case REG:
1873 case SCRATCH:
1874 return 0;
1876 case ASM_INPUT:
1877 case UNSPEC_VOLATILE:
1878 case TRAP_IF:
1879 return 1;
1881 case ASM_OPERANDS:
1882 return MEM_VOLATILE_P (x);
1884 /* Memory ref can trap unless it's a static var or a stack slot. */
1885 case MEM:
1886 return rtx_addr_can_trap_p (XEXP (x, 0));
1888 /* Division by a non-constant might trap. */
1889 case DIV:
1890 case MOD:
1891 case UDIV:
1892 case UMOD:
1893 if (! CONSTANT_P (XEXP (x, 1))
1894 || GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
1895 return 1;
1896 /* This was const0_rtx, but by not using that,
1897 we can link this file into other programs. */
1898 if (GET_CODE (XEXP (x, 1)) == CONST_INT && INTVAL (XEXP (x, 1)) == 0)
1899 return 1;
1900 break;
1902 case EXPR_LIST:
1903 /* An EXPR_LIST is used to represent a function call. This
1904 certainly may trap. */
1905 return 1;
1907 case GE:
1908 case GT:
1909 case LE:
1910 case LT:
1911 case COMPARE:
1912 /* Some floating point comparisons may trap. */
1913 /* ??? There is no machine independent way to check for tests that trap
1914 when COMPARE is used, though many targets do make this distinction.
1915 For instance, sparc uses CCFPE for compares which generate exceptions
1916 and CCFP for compares which do not generate exceptions. */
1917 if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
1918 return 1;
1919 /* But often the compare has some CC mode, so check operand
1920 modes as well. */
1921 if (GET_MODE_CLASS (GET_MODE (XEXP (x, 0))) == MODE_FLOAT
1922 || GET_MODE_CLASS (GET_MODE (XEXP (x, 1))) == MODE_FLOAT)
1923 return 1;
1924 break;
1926 default:
1927 /* Any floating arithmetic may trap. */
1928 if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
1929 return 1;
1932 fmt = GET_RTX_FORMAT (code);
1933 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
1935 if (fmt[i] == 'e')
1937 if (may_trap_p (XEXP (x, i)))
1938 return 1;
1940 else if (fmt[i] == 'E')
1942 register int j;
1943 for (j = 0; j < XVECLEN (x, i); j++)
1944 if (may_trap_p (XVECEXP (x, i, j)))
1945 return 1;
1948 return 0;
1951 /* Return nonzero if X contains a comparison that is not either EQ or NE,
1952 i.e., an inequality. */
1955 inequality_comparisons_p (x)
1956 rtx x;
1958 register const char *fmt;
1959 register int len, i;
1960 register enum rtx_code code = GET_CODE (x);
1962 switch (code)
1964 case REG:
1965 case SCRATCH:
1966 case PC:
1967 case CC0:
1968 case CONST_INT:
1969 case CONST_DOUBLE:
1970 case CONST:
1971 case LABEL_REF:
1972 case SYMBOL_REF:
1973 return 0;
1975 case LT:
1976 case LTU:
1977 case GT:
1978 case GTU:
1979 case LE:
1980 case LEU:
1981 case GE:
1982 case GEU:
1983 return 1;
1985 default:
1986 break;
1989 len = GET_RTX_LENGTH (code);
1990 fmt = GET_RTX_FORMAT (code);
1992 for (i = 0; i < len; i++)
1994 if (fmt[i] == 'e')
1996 if (inequality_comparisons_p (XEXP (x, i)))
1997 return 1;
1999 else if (fmt[i] == 'E')
2001 register int j;
2002 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
2003 if (inequality_comparisons_p (XVECEXP (x, i, j)))
2004 return 1;
2008 return 0;
2011 /* Replace any occurrence of FROM in X with TO. The function does
2012 not enter into CONST_DOUBLE for the replace.
2014 Note that copying is not done so X must not be shared unless all copies
2015 are to be modified. */
2018 replace_rtx (x, from, to)
2019 rtx x, from, to;
2021 register int i, j;
2022 register const char *fmt;
2024 /* The following prevents loops occurrence when we change MEM in
2025 CONST_DOUBLE onto the same CONST_DOUBLE. */
2026 if (x != 0 && GET_CODE (x) == CONST_DOUBLE)
2027 return x;
2029 if (x == from)
2030 return to;
2032 /* Allow this function to make replacements in EXPR_LISTs. */
2033 if (x == 0)
2034 return 0;
2036 fmt = GET_RTX_FORMAT (GET_CODE (x));
2037 for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
2039 if (fmt[i] == 'e')
2040 XEXP (x, i) = replace_rtx (XEXP (x, i), from, to);
2041 else if (fmt[i] == 'E')
2042 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
2043 XVECEXP (x, i, j) = replace_rtx (XVECEXP (x, i, j), from, to);
2046 return x;
2049 /* Throughout the rtx X, replace many registers according to REG_MAP.
2050 Return the replacement for X (which may be X with altered contents).
2051 REG_MAP[R] is the replacement for register R, or 0 for don't replace.
2052 NREGS is the length of REG_MAP; regs >= NREGS are not mapped.
2054 We only support REG_MAP entries of REG or SUBREG. Also, hard registers
2055 should not be mapped to pseudos or vice versa since validate_change
2056 is not called.
2058 If REPLACE_DEST is 1, replacements are also done in destinations;
2059 otherwise, only sources are replaced. */
2062 replace_regs (x, reg_map, nregs, replace_dest)
2063 rtx x;
2064 rtx *reg_map;
2065 unsigned int nregs;
2066 int replace_dest;
2068 register enum rtx_code code;
2069 register int i;
2070 register const char *fmt;
2072 if (x == 0)
2073 return x;
2075 code = GET_CODE (x);
2076 switch (code)
2078 case SCRATCH:
2079 case PC:
2080 case CC0:
2081 case CONST_INT:
2082 case CONST_DOUBLE:
2083 case CONST:
2084 case SYMBOL_REF:
2085 case LABEL_REF:
2086 return x;
2088 case REG:
2089 /* Verify that the register has an entry before trying to access it. */
2090 if (REGNO (x) < nregs && reg_map[REGNO (x)] != 0)
2092 /* SUBREGs can't be shared. Always return a copy to ensure that if
2093 this replacement occurs more than once then each instance will
2094 get distinct rtx. */
2095 if (GET_CODE (reg_map[REGNO (x)]) == SUBREG)
2096 return copy_rtx (reg_map[REGNO (x)]);
2097 return reg_map[REGNO (x)];
2099 return x;
2101 case SUBREG:
2102 /* Prevent making nested SUBREGs. */
2103 if (GET_CODE (SUBREG_REG (x)) == REG && REGNO (SUBREG_REG (x)) < nregs
2104 && reg_map[REGNO (SUBREG_REG (x))] != 0
2105 && GET_CODE (reg_map[REGNO (SUBREG_REG (x))]) == SUBREG)
2107 rtx map_val = reg_map[REGNO (SUBREG_REG (x))];
2108 rtx map_inner = SUBREG_REG (map_val);
2110 if (GET_MODE (x) == GET_MODE (map_inner))
2111 return map_inner;
2112 else
2114 /* We cannot call gen_rtx here since we may be linked with
2115 genattrtab.c. */
2116 /* Let's try clobbering the incoming SUBREG and see
2117 if this is really safe. */
2118 SUBREG_REG (x) = map_inner;
2119 SUBREG_WORD (x) += SUBREG_WORD (map_val);
2120 return x;
2121 #if 0
2122 rtx new = rtx_alloc (SUBREG);
2123 PUT_MODE (new, GET_MODE (x));
2124 SUBREG_REG (new) = map_inner;
2125 SUBREG_WORD (new) = SUBREG_WORD (x) + SUBREG_WORD (map_val);
2126 #endif
2129 break;
2131 case SET:
2132 if (replace_dest)
2133 SET_DEST (x) = replace_regs (SET_DEST (x), reg_map, nregs, 0);
2135 else if (GET_CODE (SET_DEST (x)) == MEM
2136 || GET_CODE (SET_DEST (x)) == STRICT_LOW_PART)
2137 /* Even if we are not to replace destinations, replace register if it
2138 is CONTAINED in destination (destination is memory or
2139 STRICT_LOW_PART). */
2140 XEXP (SET_DEST (x), 0) = replace_regs (XEXP (SET_DEST (x), 0),
2141 reg_map, nregs, 0);
2142 else if (GET_CODE (SET_DEST (x)) == ZERO_EXTRACT)
2143 /* Similarly, for ZERO_EXTRACT we replace all operands. */
2144 break;
2146 SET_SRC (x) = replace_regs (SET_SRC (x), reg_map, nregs, 0);
2147 return x;
2149 default:
2150 break;
2153 fmt = GET_RTX_FORMAT (code);
2154 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2156 if (fmt[i] == 'e')
2157 XEXP (x, i) = replace_regs (XEXP (x, i), reg_map, nregs, replace_dest);
2158 else if (fmt[i] == 'E')
2160 register int j;
2161 for (j = 0; j < XVECLEN (x, i); j++)
2162 XVECEXP (x, i, j) = replace_regs (XVECEXP (x, i, j), reg_map,
2163 nregs, replace_dest);
2166 return x;
2169 /* A subroutine of computed_jump_p, return 1 if X contains a REG or MEM or
2170 constant that is not in the constant pool and not in the condition
2171 of an IF_THEN_ELSE. */
2173 static int
2174 computed_jump_p_1 (x)
2175 rtx x;
2177 enum rtx_code code = GET_CODE (x);
2178 int i, j;
2179 const char *fmt;
2181 switch (code)
2183 case LABEL_REF:
2184 case PC:
2185 return 0;
2187 case CONST:
2188 case CONST_INT:
2189 case CONST_DOUBLE:
2190 case SYMBOL_REF:
2191 case REG:
2192 return 1;
2194 case MEM:
2195 return ! (GET_CODE (XEXP (x, 0)) == SYMBOL_REF
2196 && CONSTANT_POOL_ADDRESS_P (XEXP (x, 0)));
2198 case IF_THEN_ELSE:
2199 return (computed_jump_p_1 (XEXP (x, 1))
2200 || computed_jump_p_1 (XEXP (x, 2)));
2202 default:
2203 break;
2206 fmt = GET_RTX_FORMAT (code);
2207 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2209 if (fmt[i] == 'e'
2210 && computed_jump_p_1 (XEXP (x, i)))
2211 return 1;
2213 else if (fmt[i] == 'E')
2214 for (j = 0; j < XVECLEN (x, i); j++)
2215 if (computed_jump_p_1 (XVECEXP (x, i, j)))
2216 return 1;
2219 return 0;
2222 /* Return nonzero if INSN is an indirect jump (aka computed jump).
2224 Tablejumps and casesi insns are not considered indirect jumps;
2225 we can recognize them by a (use (label_ref)). */
2228 computed_jump_p (insn)
2229 rtx insn;
2231 int i;
2232 if (GET_CODE (insn) == JUMP_INSN)
2234 rtx pat = PATTERN (insn);
2236 if (find_reg_note (insn, REG_LABEL, NULL_RTX))
2237 return 0;
2238 else if (GET_CODE (pat) == PARALLEL)
2240 int len = XVECLEN (pat, 0);
2241 int has_use_labelref = 0;
2243 for (i = len - 1; i >= 0; i--)
2244 if (GET_CODE (XVECEXP (pat, 0, i)) == USE
2245 && (GET_CODE (XEXP (XVECEXP (pat, 0, i), 0))
2246 == LABEL_REF))
2247 has_use_labelref = 1;
2249 if (! has_use_labelref)
2250 for (i = len - 1; i >= 0; i--)
2251 if (GET_CODE (XVECEXP (pat, 0, i)) == SET
2252 && SET_DEST (XVECEXP (pat, 0, i)) == pc_rtx
2253 && computed_jump_p_1 (SET_SRC (XVECEXP (pat, 0, i))))
2254 return 1;
2256 else if (GET_CODE (pat) == SET
2257 && SET_DEST (pat) == pc_rtx
2258 && computed_jump_p_1 (SET_SRC (pat)))
2259 return 1;
2261 return 0;
2264 /* Traverse X via depth-first search, calling F for each
2265 sub-expression (including X itself). F is also passed the DATA.
2266 If F returns -1, do not traverse sub-expressions, but continue
2267 traversing the rest of the tree. If F ever returns any other
2268 non-zero value, stop the traversal, and return the value returned
2269 by F. Otherwise, return 0. This function does not traverse inside
2270 tree structure that contains RTX_EXPRs, or into sub-expressions
2271 whose format code is `0' since it is not known whether or not those
2272 codes are actually RTL.
2274 This routine is very general, and could (should?) be used to
2275 implement many of the other routines in this file. */
2278 for_each_rtx (x, f, data)
2279 rtx *x;
2280 rtx_function f;
2281 void *data;
2283 int result;
2284 int length;
2285 const char* format;
2286 int i;
2288 /* Call F on X. */
2289 result = (*f)(x, data);
2290 if (result == -1)
2291 /* Do not traverse sub-expressions. */
2292 return 0;
2293 else if (result != 0)
2294 /* Stop the traversal. */
2295 return result;
2297 if (*x == NULL_RTX)
2298 /* There are no sub-expressions. */
2299 return 0;
2301 length = GET_RTX_LENGTH (GET_CODE (*x));
2302 format = GET_RTX_FORMAT (GET_CODE (*x));
2304 for (i = 0; i < length; ++i)
2306 switch (format[i])
2308 case 'e':
2309 result = for_each_rtx (&XEXP (*x, i), f, data);
2310 if (result != 0)
2311 return result;
2312 break;
2314 case 'V':
2315 case 'E':
2316 if (XVEC (*x, i) != 0)
2318 int j;
2319 for (j = 0; j < XVECLEN (*x, i); ++j)
2321 result = for_each_rtx (&XVECEXP (*x, i, j), f, data);
2322 if (result != 0)
2323 return result;
2326 break;
2328 default:
2329 /* Nothing to do. */
2330 break;
2335 return 0;
2338 /* Searches X for any reference to REGNO, returning the rtx of the
2339 reference found if any. Otherwise, returns NULL_RTX. */
2342 regno_use_in (regno, x)
2343 unsigned int regno;
2344 rtx x;
2346 register const char *fmt;
2347 int i, j;
2348 rtx tem;
2350 if (GET_CODE (x) == REG && REGNO (x) == regno)
2351 return x;
2353 fmt = GET_RTX_FORMAT (GET_CODE (x));
2354 for (i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; i--)
2356 if (fmt[i] == 'e')
2358 if ((tem = regno_use_in (regno, XEXP (x, i))))
2359 return tem;
2361 else if (fmt[i] == 'E')
2362 for (j = XVECLEN (x, i) - 1; j >= 0; j--)
2363 if ((tem = regno_use_in (regno , XVECEXP (x, i, j))))
2364 return tem;
2367 return NULL_RTX;
2371 /* Return 1 if X is an autoincrement side effect and the register is
2372 not the stack pointer. */
2374 auto_inc_p (x)
2375 rtx x;
2377 switch (GET_CODE (x))
2379 case PRE_INC:
2380 case POST_INC:
2381 case PRE_DEC:
2382 case POST_DEC:
2383 case PRE_MODIFY:
2384 case POST_MODIFY:
2385 /* There are no REG_INC notes for SP. */
2386 if (XEXP (x, 0) != stack_pointer_rtx)
2387 return 1;
2388 default:
2389 break;
2391 return 0;
2394 /* Return 1 if the sequence of instructions beginning with FROM and up
2395 to and including TO is safe to move. If NEW_TO is non-NULL, and
2396 the sequence is not already safe to move, but can be easily
2397 extended to a sequence which is safe, then NEW_TO will point to the
2398 end of the extended sequence.
2400 For now, this function only checks that the region contains whole
2401 exception regions, but it could be extended to check additional
2402 conditions as well. */
2405 insns_safe_to_move_p (from, to, new_to)
2406 rtx from;
2407 rtx to;
2408 rtx *new_to;
2410 int eh_region_count = 0;
2411 int past_to_p = 0;
2412 rtx r = from;
2414 /* By default, assume the end of the region will be what was
2415 suggested. */
2416 if (new_to)
2417 *new_to = to;
2419 while (r)
2421 if (GET_CODE (r) == NOTE)
2423 switch (NOTE_LINE_NUMBER (r))
2425 case NOTE_INSN_EH_REGION_BEG:
2426 ++eh_region_count;
2427 break;
2429 case NOTE_INSN_EH_REGION_END:
2430 if (eh_region_count == 0)
2431 /* This sequence of instructions contains the end of
2432 an exception region, but not he beginning. Moving
2433 it will cause chaos. */
2434 return 0;
2436 --eh_region_count;
2437 break;
2439 default:
2440 break;
2443 else if (past_to_p)
2444 /* If we've passed TO, and we see a non-note instruction, we
2445 can't extend the sequence to a movable sequence. */
2446 return 0;
2448 if (r == to)
2450 if (!new_to)
2451 /* It's OK to move the sequence if there were matched sets of
2452 exception region notes. */
2453 return eh_region_count == 0;
2455 past_to_p = 1;
2458 /* It's OK to move the sequence if there were matched sets of
2459 exception region notes. */
2460 if (past_to_p && eh_region_count == 0)
2462 *new_to = r;
2463 return 1;
2466 /* Go to the next instruction. */
2467 r = NEXT_INSN (r);
2470 return 0;
2473 /* Return non-zero if IN contains a piece of rtl that has the address LOC */
2475 loc_mentioned_in_p (loc, in)
2476 rtx *loc, in;
2478 enum rtx_code code = GET_CODE (in);
2479 const char *fmt = GET_RTX_FORMAT (code);
2480 int i, j;
2482 for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
2484 if (loc == &in->fld[i].rtx)
2485 return 1;
2486 if (fmt[i] == 'e')
2488 if (loc_mentioned_in_p (loc, XEXP (in, i)))
2489 return 1;
2491 else if (fmt[i] == 'E')
2492 for (j = XVECLEN (in, i) - 1; j >= 0; j--)
2493 if (loc_mentioned_in_p (loc, XVECEXP (in, i, j)))
2494 return 1;
2496 return 0;