1 /* Optimize jump instructions, for GNU compiler.
2 Copyright (C) 1987, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997
3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
4 Free Software Foundation, Inc.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
23 /* This is the pathetic reminder of old fame of the jump-optimization pass
24 of the compiler. Now it contains basically set of utility function to
27 Each CODE_LABEL has a count of the times it is used
28 stored in the LABEL_NUSES internal field, and each JUMP_INSN
29 has one label that it refers to stored in the
30 JUMP_LABEL internal field. With this we can detect labels that
31 become unused because of the deletion of all the jumps that
32 formerly used them. The JUMP_LABEL info is sometimes looked
35 The subroutines redirect_jump and invert_jump are used
36 from other passes as well. */
40 #include "coretypes.h"
45 #include "hard-reg-set.h"
47 #include "insn-config.h"
48 #include "insn-attr.h"
54 #include "diagnostic.h"
59 #include "tree-pass.h"
62 /* Optimize jump y; x: ... y: jumpif... x?
63 Don't know if it is worth bothering with. */
64 /* Optimize two cases of conditional jump to conditional jump?
65 This can never delete any instruction or make anything dead,
66 or even change what is live at any point.
67 So perhaps let combiner do it. */
69 static void init_label_info (rtx
);
70 static void mark_all_labels (rtx
);
71 static void delete_computation (rtx
);
72 static void redirect_exp_1 (rtx
*, rtx
, rtx
, rtx
);
73 static int invert_exp_1 (rtx
, rtx
);
74 static int returnjump_p_1 (rtx
*, void *);
75 static void delete_prior_computation (rtx
, rtx
);
77 /* Alternate entry into the jump optimizer. This entry point only rebuilds
78 the JUMP_LABEL field in jumping insns and REG_LABEL notes in non-jumping
81 rebuild_jump_labels (rtx f
)
85 timevar_push (TV_REBUILD_JUMP
);
89 /* Keep track of labels used from static data; we don't track them
90 closely enough to delete them here, so make sure their reference
91 count doesn't drop to zero. */
93 for (insn
= forced_labels
; insn
; insn
= XEXP (insn
, 1))
94 if (LABEL_P (XEXP (insn
, 0)))
95 LABEL_NUSES (XEXP (insn
, 0))++;
96 timevar_pop (TV_REBUILD_JUMP
);
99 /* Some old code expects exactly one BARRIER as the NEXT_INSN of a
100 non-fallthru insn. This is not generally true, as multiple barriers
101 may have crept in, or the BARRIER may be separated from the last
102 real insn by one or more NOTEs.
104 This simple pass moves barriers and removes duplicates so that the
108 cleanup_barriers (void)
110 rtx insn
, next
, prev
;
111 for (insn
= get_insns (); insn
; insn
= next
)
113 next
= NEXT_INSN (insn
);
114 if (BARRIER_P (insn
))
116 prev
= prev_nonnote_insn (insn
);
117 if (BARRIER_P (prev
))
119 else if (prev
!= PREV_INSN (insn
))
120 reorder_insns (insn
, insn
, prev
);
126 struct tree_opt_pass pass_cleanup_barriers
=
128 "barriers", /* name */
130 cleanup_barriers
, /* execute */
133 0, /* static_pass_number */
135 0, /* properties_required */
136 0, /* properties_provided */
137 0, /* properties_destroyed */
138 0, /* todo_flags_start */
139 TODO_dump_func
, /* todo_flags_finish */
144 purge_line_number_notes (void)
148 /* Delete extraneous line number notes.
149 Note that two consecutive notes for different lines are not really
150 extraneous. There should be some indication where that line belonged,
151 even if it became empty. */
153 for (insn
= get_insns (); insn
; insn
= NEXT_INSN (insn
))
156 if (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_FUNCTION_BEG
)
157 /* Any previous line note was for the prologue; gdb wants a new
158 note after the prologue even if it is for the same line. */
159 last_note
= NULL_RTX
;
160 else if (NOTE_LINE_NUMBER (insn
) >= 0)
162 /* Delete this note if it is identical to previous note. */
164 #ifdef USE_MAPPED_LOCATION
165 && NOTE_SOURCE_LOCATION (insn
) == NOTE_SOURCE_LOCATION (last_note
)
167 && NOTE_SOURCE_FILE (insn
) == NOTE_SOURCE_FILE (last_note
)
168 && NOTE_LINE_NUMBER (insn
) == NOTE_LINE_NUMBER (last_note
)
172 delete_related_insns (insn
);
182 struct tree_opt_pass pass_purge_lineno_notes
=
184 "elnotes", /* name */
186 purge_line_number_notes
, /* execute */
189 0, /* static_pass_number */
191 0, /* properties_required */
192 0, /* properties_provided */
193 0, /* properties_destroyed */
194 0, /* todo_flags_start */
195 TODO_dump_func
, /* todo_flags_finish */
200 /* Initialize LABEL_NUSES and JUMP_LABEL fields. Delete any REG_LABEL
201 notes whose labels don't occur in the insn any more. Returns the
202 largest INSN_UID found. */
204 init_label_info (rtx f
)
208 for (insn
= f
; insn
; insn
= NEXT_INSN (insn
))
210 LABEL_NUSES (insn
) = (LABEL_PRESERVE_P (insn
) != 0);
211 else if (JUMP_P (insn
))
212 JUMP_LABEL (insn
) = 0;
213 else if (NONJUMP_INSN_P (insn
) || CALL_P (insn
))
217 for (note
= REG_NOTES (insn
); note
; note
= next
)
219 next
= XEXP (note
, 1);
220 if (REG_NOTE_KIND (note
) == REG_LABEL
221 && ! reg_mentioned_p (XEXP (note
, 0), PATTERN (insn
)))
222 remove_note (insn
, note
);
227 /* Mark the label each jump jumps to.
228 Combine consecutive labels, and count uses of labels. */
231 mark_all_labels (rtx f
)
235 for (insn
= f
; insn
; insn
= NEXT_INSN (insn
))
238 mark_jump_label (PATTERN (insn
), insn
, 0);
239 if (! INSN_DELETED_P (insn
) && JUMP_P (insn
))
241 /* When we know the LABEL_REF contained in a REG used in
242 an indirect jump, we'll have a REG_LABEL note so that
243 flow can tell where it's going. */
244 if (JUMP_LABEL (insn
) == 0)
246 rtx label_note
= find_reg_note (insn
, REG_LABEL
, NULL_RTX
);
249 /* But a LABEL_REF around the REG_LABEL note, so
250 that we can canonicalize it. */
251 rtx label_ref
= gen_rtx_LABEL_REF (Pmode
,
252 XEXP (label_note
, 0));
254 mark_jump_label (label_ref
, insn
, 0);
255 XEXP (label_note
, 0) = XEXP (label_ref
, 0);
256 JUMP_LABEL (insn
) = XEXP (label_note
, 0);
263 /* Move all block-beg, block-end, loop-beg, loop-cont, loop-vtop, loop-end,
264 notes between START and END out before START. START and END may be such
265 notes. Returns the values of the new starting and ending insns, which
266 may be different if the original ones were such notes.
267 Return true if there were only such notes and no real instructions. */
270 squeeze_notes (rtx
* startp
, rtx
* endp
)
278 rtx past_end
= NEXT_INSN (end
);
280 for (insn
= start
; insn
!= past_end
; insn
= next
)
282 next
= NEXT_INSN (insn
);
284 && (NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_END
285 || NOTE_LINE_NUMBER (insn
) == NOTE_INSN_BLOCK_BEG
286 || NOTE_LINE_NUMBER (insn
) == NOTE_INSN_LOOP_BEG
287 || NOTE_LINE_NUMBER (insn
) == NOTE_INSN_LOOP_END
))
289 /* BLOCK_BEG or BLOCK_END notes only exist in the `final' pass. */
290 gcc_assert (NOTE_LINE_NUMBER (insn
) != NOTE_INSN_BLOCK_BEG
291 && NOTE_LINE_NUMBER (insn
) != NOTE_INSN_BLOCK_END
);
297 rtx prev
= PREV_INSN (insn
);
298 PREV_INSN (insn
) = PREV_INSN (start
);
299 NEXT_INSN (insn
) = start
;
300 NEXT_INSN (PREV_INSN (insn
)) = insn
;
301 PREV_INSN (NEXT_INSN (insn
)) = insn
;
302 NEXT_INSN (prev
) = next
;
303 PREV_INSN (next
) = prev
;
310 /* There were no real instructions. */
311 if (start
== past_end
)
321 /* Return the label before INSN, or put a new label there. */
324 get_label_before (rtx insn
)
328 /* Find an existing label at this point
329 or make a new one if there is none. */
330 label
= prev_nonnote_insn (insn
);
332 if (label
== 0 || !LABEL_P (label
))
334 rtx prev
= PREV_INSN (insn
);
336 label
= gen_label_rtx ();
337 emit_label_after (label
, prev
);
338 LABEL_NUSES (label
) = 0;
343 /* Return the label after INSN, or put a new label there. */
346 get_label_after (rtx insn
)
350 /* Find an existing label at this point
351 or make a new one if there is none. */
352 label
= next_nonnote_insn (insn
);
354 if (label
== 0 || !LABEL_P (label
))
356 label
= gen_label_rtx ();
357 emit_label_after (label
, insn
);
358 LABEL_NUSES (label
) = 0;
363 /* Given a comparison (CODE ARG0 ARG1), inside an insn, INSN, return a code
364 of reversed comparison if it is possible to do so. Otherwise return UNKNOWN.
365 UNKNOWN may be returned in case we are having CC_MODE compare and we don't
366 know whether it's source is floating point or integer comparison. Machine
367 description should define REVERSIBLE_CC_MODE and REVERSE_CONDITION macros
368 to help this function avoid overhead in these cases. */
370 reversed_comparison_code_parts (enum rtx_code code
, rtx arg0
, rtx arg1
, rtx insn
)
372 enum machine_mode mode
;
374 /* If this is not actually a comparison, we can't reverse it. */
375 if (GET_RTX_CLASS (code
) != RTX_COMPARE
376 && GET_RTX_CLASS (code
) != RTX_COMM_COMPARE
)
379 mode
= GET_MODE (arg0
);
380 if (mode
== VOIDmode
)
381 mode
= GET_MODE (arg1
);
383 /* First see if machine description supplies us way to reverse the
384 comparison. Give it priority over everything else to allow
385 machine description to do tricks. */
386 if (GET_MODE_CLASS (mode
) == MODE_CC
387 && REVERSIBLE_CC_MODE (mode
))
389 #ifdef REVERSE_CONDITION
390 return REVERSE_CONDITION (code
, mode
);
392 return reverse_condition (code
);
395 /* Try a few special cases based on the comparison code. */
404 /* It is always safe to reverse EQ and NE, even for the floating
405 point. Similarly the unsigned comparisons are never used for
406 floating point so we can reverse them in the default way. */
407 return reverse_condition (code
);
412 /* In case we already see unordered comparison, we can be sure to
413 be dealing with floating point so we don't need any more tests. */
414 return reverse_condition_maybe_unordered (code
);
419 /* We don't have safe way to reverse these yet. */
425 if (GET_MODE_CLASS (mode
) == MODE_CC
|| CC0_P (arg0
))
428 /* Try to search for the comparison to determine the real mode.
429 This code is expensive, but with sane machine description it
430 will be never used, since REVERSIBLE_CC_MODE will return true
435 for (prev
= prev_nonnote_insn (insn
);
436 prev
!= 0 && !LABEL_P (prev
);
437 prev
= prev_nonnote_insn (prev
))
439 rtx set
= set_of (arg0
, prev
);
440 if (set
&& GET_CODE (set
) == SET
441 && rtx_equal_p (SET_DEST (set
), arg0
))
443 rtx src
= SET_SRC (set
);
445 if (GET_CODE (src
) == COMPARE
)
447 rtx comparison
= src
;
448 arg0
= XEXP (src
, 0);
449 mode
= GET_MODE (arg0
);
450 if (mode
== VOIDmode
)
451 mode
= GET_MODE (XEXP (comparison
, 1));
454 /* We can get past reg-reg moves. This may be useful for model
455 of i387 comparisons that first move flag registers around. */
462 /* If register is clobbered in some ununderstandable way,
469 /* Test for an integer condition, or a floating-point comparison
470 in which NaNs can be ignored. */
471 if (GET_CODE (arg0
) == CONST_INT
472 || (GET_MODE (arg0
) != VOIDmode
473 && GET_MODE_CLASS (mode
) != MODE_CC
474 && !HONOR_NANS (mode
)))
475 return reverse_condition (code
);
480 /* A wrapper around the previous function to take COMPARISON as rtx
481 expression. This simplifies many callers. */
483 reversed_comparison_code (rtx comparison
, rtx insn
)
485 if (!COMPARISON_P (comparison
))
487 return reversed_comparison_code_parts (GET_CODE (comparison
),
488 XEXP (comparison
, 0),
489 XEXP (comparison
, 1), insn
);
492 /* Return comparison with reversed code of EXP.
493 Return NULL_RTX in case we fail to do the reversal. */
495 reversed_comparison (rtx exp
, enum machine_mode mode
)
497 enum rtx_code reversed_code
= reversed_comparison_code (exp
, NULL_RTX
);
498 if (reversed_code
== UNKNOWN
)
501 return simplify_gen_relational (reversed_code
, mode
, VOIDmode
,
502 XEXP (exp
, 0), XEXP (exp
, 1));
506 /* Given an rtx-code for a comparison, return the code for the negated
507 comparison. If no such code exists, return UNKNOWN.
509 WATCH OUT! reverse_condition is not safe to use on a jump that might
510 be acting on the results of an IEEE floating point comparison, because
511 of the special treatment of non-signaling nans in comparisons.
512 Use reversed_comparison_code instead. */
515 reverse_condition (enum rtx_code code
)
557 /* Similar, but we're allowed to generate unordered comparisons, which
558 makes it safe for IEEE floating-point. Of course, we have to recognize
559 that the target will support them too... */
562 reverse_condition_maybe_unordered (enum rtx_code code
)
600 /* Similar, but return the code when two operands of a comparison are swapped.
601 This IS safe for IEEE floating-point. */
604 swap_condition (enum rtx_code code
)
646 /* Given a comparison CODE, return the corresponding unsigned comparison.
647 If CODE is an equality comparison or already an unsigned comparison,
651 unsigned_condition (enum rtx_code code
)
677 /* Similarly, return the signed version of a comparison. */
680 signed_condition (enum rtx_code code
)
706 /* Return nonzero if CODE1 is more strict than CODE2, i.e., if the
707 truth of CODE1 implies the truth of CODE2. */
710 comparison_dominates_p (enum rtx_code code1
, enum rtx_code code2
)
712 /* UNKNOWN comparison codes can happen as a result of trying to revert
714 They can't match anything, so we have to reject them here. */
715 if (code1
== UNKNOWN
|| code2
== UNKNOWN
)
724 if (code2
== UNLE
|| code2
== UNGE
)
729 if (code2
== LE
|| code2
== LEU
|| code2
== GE
|| code2
== GEU
735 if (code2
== UNLE
|| code2
== NE
)
740 if (code2
== LE
|| code2
== NE
|| code2
== ORDERED
|| code2
== LTGT
)
745 if (code2
== UNGE
|| code2
== NE
)
750 if (code2
== GE
|| code2
== NE
|| code2
== ORDERED
|| code2
== LTGT
)
756 if (code2
== ORDERED
)
761 if (code2
== NE
|| code2
== ORDERED
)
766 if (code2
== LEU
|| code2
== NE
)
771 if (code2
== GEU
|| code2
== NE
)
776 if (code2
== NE
|| code2
== UNEQ
|| code2
== UNLE
|| code2
== UNLT
777 || code2
== UNGE
|| code2
== UNGT
)
788 /* Return 1 if INSN is an unconditional jump and nothing else. */
791 simplejump_p (rtx insn
)
793 return (JUMP_P (insn
)
794 && GET_CODE (PATTERN (insn
)) == SET
795 && GET_CODE (SET_DEST (PATTERN (insn
))) == PC
796 && GET_CODE (SET_SRC (PATTERN (insn
))) == LABEL_REF
);
799 /* Return nonzero if INSN is a (possibly) conditional jump
802 Use of this function is deprecated, since we need to support combined
803 branch and compare insns. Use any_condjump_p instead whenever possible. */
806 condjump_p (rtx insn
)
808 rtx x
= PATTERN (insn
);
810 if (GET_CODE (x
) != SET
811 || GET_CODE (SET_DEST (x
)) != PC
)
815 if (GET_CODE (x
) == LABEL_REF
)
818 return (GET_CODE (x
) == IF_THEN_ELSE
819 && ((GET_CODE (XEXP (x
, 2)) == PC
820 && (GET_CODE (XEXP (x
, 1)) == LABEL_REF
821 || GET_CODE (XEXP (x
, 1)) == RETURN
))
822 || (GET_CODE (XEXP (x
, 1)) == PC
823 && (GET_CODE (XEXP (x
, 2)) == LABEL_REF
824 || GET_CODE (XEXP (x
, 2)) == RETURN
))));
827 /* Return nonzero if INSN is a (possibly) conditional jump inside a
830 Use this function is deprecated, since we need to support combined
831 branch and compare insns. Use any_condjump_p instead whenever possible. */
834 condjump_in_parallel_p (rtx insn
)
836 rtx x
= PATTERN (insn
);
838 if (GET_CODE (x
) != PARALLEL
)
841 x
= XVECEXP (x
, 0, 0);
843 if (GET_CODE (x
) != SET
)
845 if (GET_CODE (SET_DEST (x
)) != PC
)
847 if (GET_CODE (SET_SRC (x
)) == LABEL_REF
)
849 if (GET_CODE (SET_SRC (x
)) != IF_THEN_ELSE
)
851 if (XEXP (SET_SRC (x
), 2) == pc_rtx
852 && (GET_CODE (XEXP (SET_SRC (x
), 1)) == LABEL_REF
853 || GET_CODE (XEXP (SET_SRC (x
), 1)) == RETURN
))
855 if (XEXP (SET_SRC (x
), 1) == pc_rtx
856 && (GET_CODE (XEXP (SET_SRC (x
), 2)) == LABEL_REF
857 || GET_CODE (XEXP (SET_SRC (x
), 2)) == RETURN
))
862 /* Return set of PC, otherwise NULL. */
870 pat
= PATTERN (insn
);
872 /* The set is allowed to appear either as the insn pattern or
873 the first set in a PARALLEL. */
874 if (GET_CODE (pat
) == PARALLEL
)
875 pat
= XVECEXP (pat
, 0, 0);
876 if (GET_CODE (pat
) == SET
&& GET_CODE (SET_DEST (pat
)) == PC
)
882 /* Return true when insn is an unconditional direct jump,
883 possibly bundled inside a PARALLEL. */
886 any_uncondjump_p (rtx insn
)
888 rtx x
= pc_set (insn
);
891 if (GET_CODE (SET_SRC (x
)) != LABEL_REF
)
893 if (find_reg_note (insn
, REG_NON_LOCAL_GOTO
, NULL_RTX
))
898 /* Return true when insn is a conditional jump. This function works for
899 instructions containing PC sets in PARALLELs. The instruction may have
900 various other effects so before removing the jump you must verify
903 Note that unlike condjump_p it returns false for unconditional jumps. */
906 any_condjump_p (rtx insn
)
908 rtx x
= pc_set (insn
);
913 if (GET_CODE (SET_SRC (x
)) != IF_THEN_ELSE
)
916 a
= GET_CODE (XEXP (SET_SRC (x
), 1));
917 b
= GET_CODE (XEXP (SET_SRC (x
), 2));
919 return ((b
== PC
&& (a
== LABEL_REF
|| a
== RETURN
))
920 || (a
== PC
&& (b
== LABEL_REF
|| b
== RETURN
)));
923 /* Return the label of a conditional jump. */
926 condjump_label (rtx insn
)
928 rtx x
= pc_set (insn
);
933 if (GET_CODE (x
) == LABEL_REF
)
935 if (GET_CODE (x
) != IF_THEN_ELSE
)
937 if (XEXP (x
, 2) == pc_rtx
&& GET_CODE (XEXP (x
, 1)) == LABEL_REF
)
939 if (XEXP (x
, 1) == pc_rtx
&& GET_CODE (XEXP (x
, 2)) == LABEL_REF
)
944 /* Return true if INSN is a (possibly conditional) return insn. */
947 returnjump_p_1 (rtx
*loc
, void *data ATTRIBUTE_UNUSED
)
951 return x
&& (GET_CODE (x
) == RETURN
952 || (GET_CODE (x
) == SET
&& SET_IS_RETURN_P (x
)));
956 returnjump_p (rtx insn
)
960 return for_each_rtx (&PATTERN (insn
), returnjump_p_1
, NULL
);
963 /* Return true if INSN is a jump that only transfers control and
967 onlyjump_p (rtx insn
)
974 set
= single_set (insn
);
977 if (GET_CODE (SET_DEST (set
)) != PC
)
979 if (side_effects_p (SET_SRC (set
)))
987 /* Return nonzero if X is an RTX that only sets the condition codes
988 and has no side effects. */
991 only_sets_cc0_p (rtx x
)
999 return sets_cc0_p (x
) == 1 && ! side_effects_p (x
);
1002 /* Return 1 if X is an RTX that does nothing but set the condition codes
1003 and CLOBBER or USE registers.
1004 Return -1 if X does explicitly set the condition codes,
1005 but also does other things. */
1016 if (GET_CODE (x
) == SET
&& SET_DEST (x
) == cc0_rtx
)
1018 if (GET_CODE (x
) == PARALLEL
)
1022 int other_things
= 0;
1023 for (i
= XVECLEN (x
, 0) - 1; i
>= 0; i
--)
1025 if (GET_CODE (XVECEXP (x
, 0, i
)) == SET
1026 && SET_DEST (XVECEXP (x
, 0, i
)) == cc0_rtx
)
1028 else if (GET_CODE (XVECEXP (x
, 0, i
)) == SET
)
1031 return ! sets_cc0
? 0 : other_things
? -1 : 1;
1037 /* Follow any unconditional jump at LABEL;
1038 return the ultimate label reached by any such chain of jumps.
1039 Return null if the chain ultimately leads to a return instruction.
1040 If LABEL is not followed by a jump, return LABEL.
1041 If the chain loops or we can't find end, return LABEL,
1042 since that tells caller to avoid changing the insn.
1044 If RELOAD_COMPLETED is 0, we do not chain across a USE or CLOBBER. */
1047 follow_jumps (rtx label
)
1056 && (insn
= next_active_insn (value
)) != 0
1058 && ((JUMP_LABEL (insn
) != 0 && any_uncondjump_p (insn
)
1059 && onlyjump_p (insn
))
1060 || GET_CODE (PATTERN (insn
)) == RETURN
)
1061 && (next
= NEXT_INSN (insn
))
1062 && BARRIER_P (next
));
1066 if (!reload_completed
&& flag_test_coverage
)
1068 /* ??? Optional. Disables some optimizations, but makes
1069 gcov output more accurate with -O. */
1070 for (tem
= value
; tem
!= insn
; tem
= NEXT_INSN (tem
))
1071 if (NOTE_P (tem
) && NOTE_LINE_NUMBER (tem
) > 0)
1075 /* If we have found a cycle, make the insn jump to itself. */
1076 if (JUMP_LABEL (insn
) == label
)
1079 tem
= next_active_insn (JUMP_LABEL (insn
));
1080 if (tem
&& (GET_CODE (PATTERN (tem
)) == ADDR_VEC
1081 || GET_CODE (PATTERN (tem
)) == ADDR_DIFF_VEC
))
1084 value
= JUMP_LABEL (insn
);
1092 /* Find all CODE_LABELs referred to in X, and increment their use counts.
1093 If INSN is a JUMP_INSN and there is at least one CODE_LABEL referenced
1094 in INSN, then store one of them in JUMP_LABEL (INSN).
1095 If INSN is an INSN or a CALL_INSN and there is at least one CODE_LABEL
1096 referenced in INSN, add a REG_LABEL note containing that label to INSN.
1097 Also, when there are consecutive labels, canonicalize on the last of them.
1099 Note that two labels separated by a loop-beginning note
1100 must be kept distinct if we have not yet done loop-optimization,
1101 because the gap between them is where loop-optimize
1102 will want to move invariant code to. CROSS_JUMP tells us
1103 that loop-optimization is done with. */
1106 mark_jump_label (rtx x
, rtx insn
, int in_mem
)
1108 RTX_CODE code
= GET_CODE (x
);
1131 /* If this is a constant-pool reference, see if it is a label. */
1132 if (CONSTANT_POOL_ADDRESS_P (x
))
1133 mark_jump_label (get_pool_constant (x
), insn
, in_mem
);
1138 rtx label
= XEXP (x
, 0);
1140 /* Ignore remaining references to unreachable labels that
1141 have been deleted. */
1143 && NOTE_LINE_NUMBER (label
) == NOTE_INSN_DELETED_LABEL
)
1146 gcc_assert (LABEL_P (label
));
1148 /* Ignore references to labels of containing functions. */
1149 if (LABEL_REF_NONLOCAL_P (x
))
1152 XEXP (x
, 0) = label
;
1153 if (! insn
|| ! INSN_DELETED_P (insn
))
1154 ++LABEL_NUSES (label
);
1159 JUMP_LABEL (insn
) = label
;
1162 /* Add a REG_LABEL note for LABEL unless there already
1163 is one. All uses of a label, except for labels
1164 that are the targets of jumps, must have a
1166 if (! find_reg_note (insn
, REG_LABEL
, label
))
1167 REG_NOTES (insn
) = gen_rtx_INSN_LIST (REG_LABEL
, label
,
1174 /* Do walk the labels in a vector, but not the first operand of an
1175 ADDR_DIFF_VEC. Don't set the JUMP_LABEL of a vector. */
1178 if (! INSN_DELETED_P (insn
))
1180 int eltnum
= code
== ADDR_DIFF_VEC
? 1 : 0;
1182 for (i
= 0; i
< XVECLEN (x
, eltnum
); i
++)
1183 mark_jump_label (XVECEXP (x
, eltnum
, i
), NULL_RTX
, in_mem
);
1191 fmt
= GET_RTX_FORMAT (code
);
1192 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
1195 mark_jump_label (XEXP (x
, i
), insn
, in_mem
);
1196 else if (fmt
[i
] == 'E')
1199 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
1200 mark_jump_label (XVECEXP (x
, i
, j
), insn
, in_mem
);
1205 /* If all INSN does is set the pc, delete it,
1206 and delete the insn that set the condition codes for it
1207 if that's what the previous thing was. */
1210 delete_jump (rtx insn
)
1212 rtx set
= single_set (insn
);
1214 if (set
&& GET_CODE (SET_DEST (set
)) == PC
)
1215 delete_computation (insn
);
1218 /* Recursively delete prior insns that compute the value (used only by INSN
1219 which the caller is deleting) stored in the register mentioned by NOTE
1220 which is a REG_DEAD note associated with INSN. */
1223 delete_prior_computation (rtx note
, rtx insn
)
1226 rtx reg
= XEXP (note
, 0);
1228 for (our_prev
= prev_nonnote_insn (insn
);
1229 our_prev
&& (NONJUMP_INSN_P (our_prev
)
1230 || CALL_P (our_prev
));
1231 our_prev
= prev_nonnote_insn (our_prev
))
1233 rtx pat
= PATTERN (our_prev
);
1235 /* If we reach a CALL which is not calling a const function
1236 or the callee pops the arguments, then give up. */
1237 if (CALL_P (our_prev
)
1238 && (! CONST_OR_PURE_CALL_P (our_prev
)
1239 || GET_CODE (pat
) != SET
|| GET_CODE (SET_SRC (pat
)) != CALL
))
1242 /* If we reach a SEQUENCE, it is too complex to try to
1243 do anything with it, so give up. We can be run during
1244 and after reorg, so SEQUENCE rtl can legitimately show
1246 if (GET_CODE (pat
) == SEQUENCE
)
1249 if (GET_CODE (pat
) == USE
1250 && NONJUMP_INSN_P (XEXP (pat
, 0)))
1251 /* reorg creates USEs that look like this. We leave them
1252 alone because reorg needs them for its own purposes. */
1255 if (reg_set_p (reg
, pat
))
1257 if (side_effects_p (pat
) && !CALL_P (our_prev
))
1260 if (GET_CODE (pat
) == PARALLEL
)
1262 /* If we find a SET of something else, we can't
1267 for (i
= 0; i
< XVECLEN (pat
, 0); i
++)
1269 rtx part
= XVECEXP (pat
, 0, i
);
1271 if (GET_CODE (part
) == SET
1272 && SET_DEST (part
) != reg
)
1276 if (i
== XVECLEN (pat
, 0))
1277 delete_computation (our_prev
);
1279 else if (GET_CODE (pat
) == SET
1280 && REG_P (SET_DEST (pat
)))
1282 int dest_regno
= REGNO (SET_DEST (pat
));
1285 + (dest_regno
< FIRST_PSEUDO_REGISTER
1286 ? hard_regno_nregs
[dest_regno
]
1287 [GET_MODE (SET_DEST (pat
))] : 1));
1288 int regno
= REGNO (reg
);
1291 + (regno
< FIRST_PSEUDO_REGISTER
1292 ? hard_regno_nregs
[regno
][GET_MODE (reg
)] : 1));
1294 if (dest_regno
>= regno
1295 && dest_endregno
<= endregno
)
1296 delete_computation (our_prev
);
1298 /* We may have a multi-word hard register and some, but not
1299 all, of the words of the register are needed in subsequent
1300 insns. Write REG_UNUSED notes for those parts that were not
1302 else if (dest_regno
<= regno
1303 && dest_endregno
>= endregno
)
1307 REG_NOTES (our_prev
)
1308 = gen_rtx_EXPR_LIST (REG_UNUSED
, reg
,
1309 REG_NOTES (our_prev
));
1311 for (i
= dest_regno
; i
< dest_endregno
; i
++)
1312 if (! find_regno_note (our_prev
, REG_UNUSED
, i
))
1315 if (i
== dest_endregno
)
1316 delete_computation (our_prev
);
1323 /* If PAT references the register that dies here, it is an
1324 additional use. Hence any prior SET isn't dead. However, this
1325 insn becomes the new place for the REG_DEAD note. */
1326 if (reg_overlap_mentioned_p (reg
, pat
))
1328 XEXP (note
, 1) = REG_NOTES (our_prev
);
1329 REG_NOTES (our_prev
) = note
;
1335 /* Delete INSN and recursively delete insns that compute values used only
1336 by INSN. This uses the REG_DEAD notes computed during flow analysis.
1337 If we are running before flow.c, we need do nothing since flow.c will
1338 delete dead code. We also can't know if the registers being used are
1339 dead or not at this point.
1341 Otherwise, look at all our REG_DEAD notes. If a previous insn does
1342 nothing other than set a register that dies in this insn, we can delete
1345 On machines with CC0, if CC0 is used in this insn, we may be able to
1346 delete the insn that set it. */
1349 delete_computation (rtx insn
)
1354 if (reg_referenced_p (cc0_rtx
, PATTERN (insn
)))
1356 rtx prev
= prev_nonnote_insn (insn
);
1357 /* We assume that at this stage
1358 CC's are always set explicitly
1359 and always immediately before the jump that
1360 will use them. So if the previous insn
1361 exists to set the CC's, delete it
1362 (unless it performs auto-increments, etc.). */
1363 if (prev
&& NONJUMP_INSN_P (prev
)
1364 && sets_cc0_p (PATTERN (prev
)))
1366 if (sets_cc0_p (PATTERN (prev
)) > 0
1367 && ! side_effects_p (PATTERN (prev
)))
1368 delete_computation (prev
);
1370 /* Otherwise, show that cc0 won't be used. */
1371 REG_NOTES (prev
) = gen_rtx_EXPR_LIST (REG_UNUSED
,
1372 cc0_rtx
, REG_NOTES (prev
));
1377 for (note
= REG_NOTES (insn
); note
; note
= next
)
1379 next
= XEXP (note
, 1);
1381 if (REG_NOTE_KIND (note
) != REG_DEAD
1382 /* Verify that the REG_NOTE is legitimate. */
1383 || !REG_P (XEXP (note
, 0)))
1386 delete_prior_computation (note
, insn
);
1389 delete_related_insns (insn
);
1392 /* Delete insn INSN from the chain of insns and update label ref counts
1393 and delete insns now unreachable.
1395 Returns the first insn after INSN that was not deleted.
1397 Usage of this instruction is deprecated. Use delete_insn instead and
1398 subsequent cfg_cleanup pass to delete unreachable code if needed. */
1401 delete_related_insns (rtx insn
)
1403 int was_code_label
= (LABEL_P (insn
));
1405 rtx next
= NEXT_INSN (insn
), prev
= PREV_INSN (insn
);
1407 while (next
&& INSN_DELETED_P (next
))
1408 next
= NEXT_INSN (next
);
1410 /* This insn is already deleted => return first following nondeleted. */
1411 if (INSN_DELETED_P (insn
))
1416 /* If instruction is followed by a barrier,
1417 delete the barrier too. */
1419 if (next
!= 0 && BARRIER_P (next
))
1422 /* If deleting a jump, decrement the count of the label,
1423 and delete the label if it is now unused. */
1425 if (JUMP_P (insn
) && JUMP_LABEL (insn
))
1427 rtx lab
= JUMP_LABEL (insn
), lab_next
;
1429 if (LABEL_NUSES (lab
) == 0)
1431 /* This can delete NEXT or PREV,
1432 either directly if NEXT is JUMP_LABEL (INSN),
1433 or indirectly through more levels of jumps. */
1434 delete_related_insns (lab
);
1436 /* I feel a little doubtful about this loop,
1437 but I see no clean and sure alternative way
1438 to find the first insn after INSN that is not now deleted.
1439 I hope this works. */
1440 while (next
&& INSN_DELETED_P (next
))
1441 next
= NEXT_INSN (next
);
1444 else if (tablejump_p (insn
, NULL
, &lab_next
))
1446 /* If we're deleting the tablejump, delete the dispatch table.
1447 We may not be able to kill the label immediately preceding
1448 just yet, as it might be referenced in code leading up to
1450 delete_related_insns (lab_next
);
1454 /* Likewise if we're deleting a dispatch table. */
1457 && (GET_CODE (PATTERN (insn
)) == ADDR_VEC
1458 || GET_CODE (PATTERN (insn
)) == ADDR_DIFF_VEC
))
1460 rtx pat
= PATTERN (insn
);
1461 int i
, diff_vec_p
= GET_CODE (pat
) == ADDR_DIFF_VEC
;
1462 int len
= XVECLEN (pat
, diff_vec_p
);
1464 for (i
= 0; i
< len
; i
++)
1465 if (LABEL_NUSES (XEXP (XVECEXP (pat
, diff_vec_p
, i
), 0)) == 0)
1466 delete_related_insns (XEXP (XVECEXP (pat
, diff_vec_p
, i
), 0));
1467 while (next
&& INSN_DELETED_P (next
))
1468 next
= NEXT_INSN (next
);
1472 /* Likewise for an ordinary INSN / CALL_INSN with a REG_LABEL note. */
1473 if (NONJUMP_INSN_P (insn
) || CALL_P (insn
))
1474 for (note
= REG_NOTES (insn
); note
; note
= XEXP (note
, 1))
1475 if (REG_NOTE_KIND (note
) == REG_LABEL
1476 /* This could also be a NOTE_INSN_DELETED_LABEL note. */
1477 && LABEL_P (XEXP (note
, 0)))
1478 if (LABEL_NUSES (XEXP (note
, 0)) == 0)
1479 delete_related_insns (XEXP (note
, 0));
1481 while (prev
&& (INSN_DELETED_P (prev
) || NOTE_P (prev
)))
1482 prev
= PREV_INSN (prev
);
1484 /* If INSN was a label and a dispatch table follows it,
1485 delete the dispatch table. The tablejump must have gone already.
1486 It isn't useful to fall through into a table. */
1489 && NEXT_INSN (insn
) != 0
1490 && JUMP_P (NEXT_INSN (insn
))
1491 && (GET_CODE (PATTERN (NEXT_INSN (insn
))) == ADDR_VEC
1492 || GET_CODE (PATTERN (NEXT_INSN (insn
))) == ADDR_DIFF_VEC
))
1493 next
= delete_related_insns (NEXT_INSN (insn
));
1495 /* If INSN was a label, delete insns following it if now unreachable. */
1497 if (was_code_label
&& prev
&& BARRIER_P (prev
))
1502 code
= GET_CODE (next
);
1504 && NOTE_LINE_NUMBER (next
) != NOTE_INSN_FUNCTION_END
)
1505 next
= NEXT_INSN (next
);
1506 /* Keep going past other deleted labels to delete what follows. */
1507 else if (code
== CODE_LABEL
&& INSN_DELETED_P (next
))
1508 next
= NEXT_INSN (next
);
1509 else if (code
== BARRIER
|| INSN_P (next
))
1510 /* Note: if this deletes a jump, it can cause more
1511 deletion of unreachable code, after a different label.
1512 As long as the value from this recursive call is correct,
1513 this invocation functions correctly. */
1514 next
= delete_related_insns (next
);
1523 /* Delete a range of insns from FROM to TO, inclusive.
1524 This is for the sake of peephole optimization, so assume
1525 that whatever these insns do will still be done by a new
1526 peephole insn that will replace them. */
1529 delete_for_peephole (rtx from
, rtx to
)
1535 rtx next
= NEXT_INSN (insn
);
1536 rtx prev
= PREV_INSN (insn
);
1540 INSN_DELETED_P (insn
) = 1;
1542 /* Patch this insn out of the chain. */
1543 /* We don't do this all at once, because we
1544 must preserve all NOTEs. */
1546 NEXT_INSN (prev
) = next
;
1549 PREV_INSN (next
) = prev
;
1557 /* Note that if TO is an unconditional jump
1558 we *do not* delete the BARRIER that follows,
1559 since the peephole that replaces this sequence
1560 is also an unconditional jump in that case. */
1563 /* Throughout LOC, redirect OLABEL to NLABEL. Treat null OLABEL or
1564 NLABEL as a return. Accrue modifications into the change group. */
1567 redirect_exp_1 (rtx
*loc
, rtx olabel
, rtx nlabel
, rtx insn
)
1570 RTX_CODE code
= GET_CODE (x
);
1574 if (code
== LABEL_REF
)
1576 if (XEXP (x
, 0) == olabel
)
1580 n
= gen_rtx_LABEL_REF (Pmode
, nlabel
);
1582 n
= gen_rtx_RETURN (VOIDmode
);
1584 validate_change (insn
, loc
, n
, 1);
1588 else if (code
== RETURN
&& olabel
== 0)
1591 x
= gen_rtx_LABEL_REF (Pmode
, nlabel
);
1593 x
= gen_rtx_RETURN (VOIDmode
);
1594 if (loc
== &PATTERN (insn
))
1595 x
= gen_rtx_SET (VOIDmode
, pc_rtx
, x
);
1596 validate_change (insn
, loc
, x
, 1);
1600 if (code
== SET
&& nlabel
== 0 && SET_DEST (x
) == pc_rtx
1601 && GET_CODE (SET_SRC (x
)) == LABEL_REF
1602 && XEXP (SET_SRC (x
), 0) == olabel
)
1604 validate_change (insn
, loc
, gen_rtx_RETURN (VOIDmode
), 1);
1608 fmt
= GET_RTX_FORMAT (code
);
1609 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
1612 redirect_exp_1 (&XEXP (x
, i
), olabel
, nlabel
, insn
);
1613 else if (fmt
[i
] == 'E')
1616 for (j
= 0; j
< XVECLEN (x
, i
); j
++)
1617 redirect_exp_1 (&XVECEXP (x
, i
, j
), olabel
, nlabel
, insn
);
1622 /* Make JUMP go to NLABEL instead of where it jumps now. Accrue
1623 the modifications into the change group. Return false if we did
1624 not see how to do that. */
1627 redirect_jump_1 (rtx jump
, rtx nlabel
)
1629 int ochanges
= num_validated_changes ();
1632 if (GET_CODE (PATTERN (jump
)) == PARALLEL
)
1633 loc
= &XVECEXP (PATTERN (jump
), 0, 0);
1635 loc
= &PATTERN (jump
);
1637 redirect_exp_1 (loc
, JUMP_LABEL (jump
), nlabel
, jump
);
1638 return num_validated_changes () > ochanges
;
1641 /* Make JUMP go to NLABEL instead of where it jumps now. If the old
1642 jump target label is unused as a result, it and the code following
1645 If NLABEL is zero, we are to turn the jump into a (possibly conditional)
1648 The return value will be 1 if the change was made, 0 if it wasn't
1649 (this can only occur for NLABEL == 0). */
1652 redirect_jump (rtx jump
, rtx nlabel
, int delete_unused
)
1654 rtx olabel
= JUMP_LABEL (jump
);
1656 if (nlabel
== olabel
)
1659 if (! redirect_jump_1 (jump
, nlabel
) || ! apply_change_group ())
1662 redirect_jump_2 (jump
, olabel
, nlabel
, delete_unused
, 0);
1666 /* Fix up JUMP_LABEL and label ref counts after OLABEL has been replaced with
1667 NLABEL in JUMP. If DELETE_UNUSED is non-negative, copy a
1668 NOTE_INSN_FUNCTION_END found after OLABEL to the place after NLABEL.
1669 If DELETE_UNUSED is positive, delete related insn to OLABEL if its ref
1670 count has dropped to zero. */
1672 redirect_jump_2 (rtx jump
, rtx olabel
, rtx nlabel
, int delete_unused
,
1677 JUMP_LABEL (jump
) = nlabel
;
1679 ++LABEL_NUSES (nlabel
);
1681 /* Update labels in any REG_EQUAL note. */
1682 if ((note
= find_reg_note (jump
, REG_EQUAL
, NULL_RTX
)) != NULL_RTX
)
1684 if (!nlabel
|| (invert
&& !invert_exp_1 (XEXP (note
, 0), jump
)))
1685 remove_note (jump
, note
);
1688 redirect_exp_1 (&XEXP (note
, 0), olabel
, nlabel
, jump
);
1689 confirm_change_group ();
1693 /* If we're eliding the jump over exception cleanups at the end of a
1694 function, move the function end note so that -Wreturn-type works. */
1695 if (olabel
&& nlabel
1696 && NEXT_INSN (olabel
)
1697 && NOTE_P (NEXT_INSN (olabel
))
1698 && NOTE_LINE_NUMBER (NEXT_INSN (olabel
)) == NOTE_INSN_FUNCTION_END
1699 && delete_unused
>= 0)
1700 emit_note_after (NOTE_INSN_FUNCTION_END
, nlabel
);
1702 if (olabel
&& --LABEL_NUSES (olabel
) == 0 && delete_unused
> 0
1703 /* Undefined labels will remain outside the insn stream. */
1704 && INSN_UID (olabel
))
1705 delete_related_insns (olabel
);
1707 invert_br_probabilities (jump
);
1710 /* Invert the jump condition X contained in jump insn INSN. Accrue the
1711 modifications into the change group. Return nonzero for success. */
1713 invert_exp_1 (rtx x
, rtx insn
)
1715 RTX_CODE code
= GET_CODE (x
);
1717 if (code
== IF_THEN_ELSE
)
1719 rtx comp
= XEXP (x
, 0);
1721 enum rtx_code reversed_code
;
1723 /* We can do this in two ways: The preferable way, which can only
1724 be done if this is not an integer comparison, is to reverse
1725 the comparison code. Otherwise, swap the THEN-part and ELSE-part
1726 of the IF_THEN_ELSE. If we can't do either, fail. */
1728 reversed_code
= reversed_comparison_code (comp
, insn
);
1730 if (reversed_code
!= UNKNOWN
)
1732 validate_change (insn
, &XEXP (x
, 0),
1733 gen_rtx_fmt_ee (reversed_code
,
1734 GET_MODE (comp
), XEXP (comp
, 0),
1741 validate_change (insn
, &XEXP (x
, 1), XEXP (x
, 2), 1);
1742 validate_change (insn
, &XEXP (x
, 2), tem
, 1);
1749 /* Invert the condition of the jump JUMP, and make it jump to label
1750 NLABEL instead of where it jumps now. Accrue changes into the
1751 change group. Return false if we didn't see how to perform the
1752 inversion and redirection. */
1755 invert_jump_1 (rtx jump
, rtx nlabel
)
1757 rtx x
= pc_set (jump
);
1761 ochanges
= num_validated_changes ();
1763 ok
= invert_exp_1 (SET_SRC (x
), jump
);
1766 if (num_validated_changes () == ochanges
)
1769 /* redirect_jump_1 will fail of nlabel == olabel, and the current use is
1770 in Pmode, so checking this is not merely an optimization. */
1771 return nlabel
== JUMP_LABEL (jump
) || redirect_jump_1 (jump
, nlabel
);
1774 /* Invert the condition of the jump JUMP, and make it jump to label
1775 NLABEL instead of where it jumps now. Return true if successful. */
1778 invert_jump (rtx jump
, rtx nlabel
, int delete_unused
)
1780 rtx olabel
= JUMP_LABEL (jump
);
1782 if (invert_jump_1 (jump
, nlabel
) && apply_change_group ())
1784 redirect_jump_2 (jump
, olabel
, nlabel
, delete_unused
, 1);
1792 /* Like rtx_equal_p except that it considers two REGs as equal
1793 if they renumber to the same value and considers two commutative
1794 operations to be the same if the order of the operands has been
1798 rtx_renumbered_equal_p (rtx x
, rtx y
)
1801 enum rtx_code code
= GET_CODE (x
);
1807 if ((code
== REG
|| (code
== SUBREG
&& REG_P (SUBREG_REG (x
))))
1808 && (REG_P (y
) || (GET_CODE (y
) == SUBREG
1809 && REG_P (SUBREG_REG (y
)))))
1811 int reg_x
= -1, reg_y
= -1;
1812 int byte_x
= 0, byte_y
= 0;
1814 if (GET_MODE (x
) != GET_MODE (y
))
1817 /* If we haven't done any renumbering, don't
1818 make any assumptions. */
1819 if (reg_renumber
== 0)
1820 return rtx_equal_p (x
, y
);
1824 reg_x
= REGNO (SUBREG_REG (x
));
1825 byte_x
= SUBREG_BYTE (x
);
1827 if (reg_renumber
[reg_x
] >= 0)
1829 reg_x
= subreg_regno_offset (reg_renumber
[reg_x
],
1830 GET_MODE (SUBREG_REG (x
)),
1839 if (reg_renumber
[reg_x
] >= 0)
1840 reg_x
= reg_renumber
[reg_x
];
1843 if (GET_CODE (y
) == SUBREG
)
1845 reg_y
= REGNO (SUBREG_REG (y
));
1846 byte_y
= SUBREG_BYTE (y
);
1848 if (reg_renumber
[reg_y
] >= 0)
1850 reg_y
= subreg_regno_offset (reg_renumber
[reg_y
],
1851 GET_MODE (SUBREG_REG (y
)),
1860 if (reg_renumber
[reg_y
] >= 0)
1861 reg_y
= reg_renumber
[reg_y
];
1864 return reg_x
>= 0 && reg_x
== reg_y
&& byte_x
== byte_y
;
1867 /* Now we have disposed of all the cases
1868 in which different rtx codes can match. */
1869 if (code
!= GET_CODE (y
))
1883 /* We can't assume nonlocal labels have their following insns yet. */
1884 if (LABEL_REF_NONLOCAL_P (x
) || LABEL_REF_NONLOCAL_P (y
))
1885 return XEXP (x
, 0) == XEXP (y
, 0);
1887 /* Two label-refs are equivalent if they point at labels
1888 in the same position in the instruction stream. */
1889 return (next_real_insn (XEXP (x
, 0))
1890 == next_real_insn (XEXP (y
, 0)));
1893 return XSTR (x
, 0) == XSTR (y
, 0);
1896 /* If we didn't match EQ equality above, they aren't the same. */
1903 /* (MULT:SI x y) and (MULT:HI x y) are NOT equivalent. */
1905 if (GET_MODE (x
) != GET_MODE (y
))
1908 /* For commutative operations, the RTX match if the operand match in any
1909 order. Also handle the simple binary and unary cases without a loop. */
1910 if (targetm
.commutative_p (x
, UNKNOWN
))
1911 return ((rtx_renumbered_equal_p (XEXP (x
, 0), XEXP (y
, 0))
1912 && rtx_renumbered_equal_p (XEXP (x
, 1), XEXP (y
, 1)))
1913 || (rtx_renumbered_equal_p (XEXP (x
, 0), XEXP (y
, 1))
1914 && rtx_renumbered_equal_p (XEXP (x
, 1), XEXP (y
, 0))));
1915 else if (NON_COMMUTATIVE_P (x
))
1916 return (rtx_renumbered_equal_p (XEXP (x
, 0), XEXP (y
, 0))
1917 && rtx_renumbered_equal_p (XEXP (x
, 1), XEXP (y
, 1)));
1918 else if (UNARY_P (x
))
1919 return rtx_renumbered_equal_p (XEXP (x
, 0), XEXP (y
, 0));
1921 /* Compare the elements. If any pair of corresponding elements
1922 fail to match, return 0 for the whole things. */
1924 fmt
= GET_RTX_FORMAT (code
);
1925 for (i
= GET_RTX_LENGTH (code
) - 1; i
>= 0; i
--)
1931 if (XWINT (x
, i
) != XWINT (y
, i
))
1936 if (XINT (x
, i
) != XINT (y
, i
))
1941 if (XTREE (x
, i
) != XTREE (y
, i
))
1946 if (strcmp (XSTR (x
, i
), XSTR (y
, i
)))
1951 if (! rtx_renumbered_equal_p (XEXP (x
, i
), XEXP (y
, i
)))
1956 if (XEXP (x
, i
) != XEXP (y
, i
))
1963 if (XVECLEN (x
, i
) != XVECLEN (y
, i
))
1965 for (j
= XVECLEN (x
, i
) - 1; j
>= 0; j
--)
1966 if (!rtx_renumbered_equal_p (XVECEXP (x
, i
, j
), XVECEXP (y
, i
, j
)))
1977 /* If X is a hard register or equivalent to one or a subregister of one,
1978 return the hard register number. If X is a pseudo register that was not
1979 assigned a hard register, return the pseudo register number. Otherwise,
1980 return -1. Any rtx is valid for X. */
1987 if (REGNO (x
) >= FIRST_PSEUDO_REGISTER
&& reg_renumber
[REGNO (x
)] >= 0)
1988 return reg_renumber
[REGNO (x
)];
1991 if (GET_CODE (x
) == SUBREG
)
1993 int base
= true_regnum (SUBREG_REG (x
));
1994 if (base
>= 0 && base
< FIRST_PSEUDO_REGISTER
)
1995 return base
+ subreg_regno_offset (REGNO (SUBREG_REG (x
)),
1996 GET_MODE (SUBREG_REG (x
)),
1997 SUBREG_BYTE (x
), GET_MODE (x
));
2002 /* Return regno of the register REG and handle subregs too. */
2004 reg_or_subregno (rtx reg
)
2006 if (GET_CODE (reg
) == SUBREG
)
2007 reg
= SUBREG_REG (reg
);
2008 gcc_assert (REG_P (reg
));