1 /* Decompose multiword subregs.
2 Copyright (C) 2007-2015 Free Software Foundation, Inc.
3 Contributed by Richard Henderson <rth@redhat.com>
4 Ian Lance Taylor <iant@google.com>
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 3, 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 COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
24 #include "coretypes.h"
33 #include "insn-config.h"
48 #include "tree-pass.h"
49 #include "lower-subreg.h"
53 /* Decompose multi-word pseudo-registers into individual
54 pseudo-registers when possible and profitable. This is possible
55 when all the uses of a multi-word register are via SUBREG, or are
56 copies of the register to another location. Breaking apart the
57 register permits more CSE and permits better register allocation.
58 This is profitable if the machine does not have move instructions
61 This pass only splits moves with modes that are wider than
62 word_mode and ASHIFTs, LSHIFTRTs, ASHIFTRTs and ZERO_EXTENDs with
63 integer modes that are twice the width of word_mode. The latter
64 could be generalized if there was a need to do this, but the trend in
65 architectures is to not need this.
67 There are two useful preprocessor defines for use by maintainers:
71 if you wish to see the actual cost estimates that are being used
72 for each mode wider than word mode and the cost estimates for zero
73 extension and the shifts. This can be useful when port maintainers
74 are tuning insn rtx costs.
76 #define FORCE_LOWERING 1
78 if you wish to test the pass with all the transformation forced on.
79 This can be useful for finding bugs in the transformations. */
82 #define FORCE_LOWERING 0
84 /* Bit N in this bitmap is set if regno N is used in a context in
85 which we can decompose it. */
86 static bitmap decomposable_context
;
88 /* Bit N in this bitmap is set if regno N is used in a context in
89 which it can not be decomposed. */
90 static bitmap non_decomposable_context
;
92 /* Bit N in this bitmap is set if regno N is used in a subreg
93 which changes the mode but not the size. This typically happens
94 when the register accessed as a floating-point value; we want to
95 avoid generating accesses to its subwords in integer modes. */
96 static bitmap subreg_context
;
98 /* Bit N in the bitmap in element M of this array is set if there is a
99 copy from reg M to reg N. */
100 static vec
<bitmap
> reg_copy_graph
;
102 struct target_lower_subreg default_target_lower_subreg
;
103 #if SWITCHABLE_TARGET
104 struct target_lower_subreg
*this_target_lower_subreg
105 = &default_target_lower_subreg
;
108 #define twice_word_mode \
109 this_target_lower_subreg->x_twice_word_mode
111 this_target_lower_subreg->x_choices
113 /* RTXes used while computing costs. */
115 /* Source and target registers. */
119 /* A twice_word_mode ZERO_EXTEND of SOURCE. */
122 /* A shift of SOURCE. */
125 /* A SET of TARGET. */
129 /* Return the cost of a CODE shift in mode MODE by OP1 bits, using the
130 rtxes in RTXES. SPEED_P selects between the speed and size cost. */
133 shift_cost (bool speed_p
, struct cost_rtxes
*rtxes
, enum rtx_code code
,
134 machine_mode mode
, int op1
)
136 PUT_CODE (rtxes
->shift
, code
);
137 PUT_MODE (rtxes
->shift
, mode
);
138 PUT_MODE (rtxes
->source
, mode
);
139 XEXP (rtxes
->shift
, 1) = GEN_INT (op1
);
140 return set_src_cost (rtxes
->shift
, mode
, speed_p
);
143 /* For each X in the range [0, BITS_PER_WORD), set SPLITTING[X]
144 to true if it is profitable to split a double-word CODE shift
145 of X + BITS_PER_WORD bits. SPEED_P says whether we are testing
146 for speed or size profitability.
148 Use the rtxes in RTXES to calculate costs. WORD_MOVE_ZERO_COST is
149 the cost of moving zero into a word-mode register. WORD_MOVE_COST
150 is the cost of moving between word registers. */
153 compute_splitting_shift (bool speed_p
, struct cost_rtxes
*rtxes
,
154 bool *splitting
, enum rtx_code code
,
155 int word_move_zero_cost
, int word_move_cost
)
157 int wide_cost
, narrow_cost
, upper_cost
, i
;
159 for (i
= 0; i
< BITS_PER_WORD
; i
++)
161 wide_cost
= shift_cost (speed_p
, rtxes
, code
, twice_word_mode
,
164 narrow_cost
= word_move_cost
;
166 narrow_cost
= shift_cost (speed_p
, rtxes
, code
, word_mode
, i
);
168 if (code
!= ASHIFTRT
)
169 upper_cost
= word_move_zero_cost
;
170 else if (i
== BITS_PER_WORD
- 1)
171 upper_cost
= word_move_cost
;
173 upper_cost
= shift_cost (speed_p
, rtxes
, code
, word_mode
,
177 fprintf (stderr
, "%s %s by %d: original cost %d, split cost %d + %d\n",
178 GET_MODE_NAME (twice_word_mode
), GET_RTX_NAME (code
),
179 i
+ BITS_PER_WORD
, wide_cost
, narrow_cost
, upper_cost
);
181 if (FORCE_LOWERING
|| wide_cost
>= narrow_cost
+ upper_cost
)
186 /* Compute what we should do when optimizing for speed or size; SPEED_P
187 selects which. Use RTXES for computing costs. */
190 compute_costs (bool speed_p
, struct cost_rtxes
*rtxes
)
193 int word_move_zero_cost
, word_move_cost
;
195 PUT_MODE (rtxes
->target
, word_mode
);
196 SET_SRC (rtxes
->set
) = CONST0_RTX (word_mode
);
197 word_move_zero_cost
= set_rtx_cost (rtxes
->set
, speed_p
);
199 SET_SRC (rtxes
->set
) = rtxes
->source
;
200 word_move_cost
= set_rtx_cost (rtxes
->set
, speed_p
);
203 fprintf (stderr
, "%s move: from zero cost %d, from reg cost %d\n",
204 GET_MODE_NAME (word_mode
), word_move_zero_cost
, word_move_cost
);
206 for (i
= 0; i
< MAX_MACHINE_MODE
; i
++)
208 machine_mode mode
= (machine_mode
) i
;
209 int factor
= GET_MODE_SIZE (mode
) / UNITS_PER_WORD
;
214 PUT_MODE (rtxes
->target
, mode
);
215 PUT_MODE (rtxes
->source
, mode
);
216 mode_move_cost
= set_rtx_cost (rtxes
->set
, speed_p
);
219 fprintf (stderr
, "%s move: original cost %d, split cost %d * %d\n",
220 GET_MODE_NAME (mode
), mode_move_cost
,
221 word_move_cost
, factor
);
223 if (FORCE_LOWERING
|| mode_move_cost
>= word_move_cost
* factor
)
225 choices
[speed_p
].move_modes_to_split
[i
] = true;
226 choices
[speed_p
].something_to_do
= true;
231 /* For the moves and shifts, the only case that is checked is one
232 where the mode of the target is an integer mode twice the width
235 If it is not profitable to split a double word move then do not
236 even consider the shifts or the zero extension. */
237 if (choices
[speed_p
].move_modes_to_split
[(int) twice_word_mode
])
241 /* The only case here to check to see if moving the upper part with a
242 zero is cheaper than doing the zext itself. */
243 PUT_MODE (rtxes
->source
, word_mode
);
244 zext_cost
= set_src_cost (rtxes
->zext
, twice_word_mode
, speed_p
);
247 fprintf (stderr
, "%s %s: original cost %d, split cost %d + %d\n",
248 GET_MODE_NAME (twice_word_mode
), GET_RTX_NAME (ZERO_EXTEND
),
249 zext_cost
, word_move_cost
, word_move_zero_cost
);
251 if (FORCE_LOWERING
|| zext_cost
>= word_move_cost
+ word_move_zero_cost
)
252 choices
[speed_p
].splitting_zext
= true;
254 compute_splitting_shift (speed_p
, rtxes
,
255 choices
[speed_p
].splitting_ashift
, ASHIFT
,
256 word_move_zero_cost
, word_move_cost
);
257 compute_splitting_shift (speed_p
, rtxes
,
258 choices
[speed_p
].splitting_lshiftrt
, LSHIFTRT
,
259 word_move_zero_cost
, word_move_cost
);
260 compute_splitting_shift (speed_p
, rtxes
,
261 choices
[speed_p
].splitting_ashiftrt
, ASHIFTRT
,
262 word_move_zero_cost
, word_move_cost
);
266 /* Do one-per-target initialisation. This involves determining
267 which operations on the machine are profitable. If none are found,
268 then the pass just returns when called. */
271 init_lower_subreg (void)
273 struct cost_rtxes rtxes
;
275 memset (this_target_lower_subreg
, 0, sizeof (*this_target_lower_subreg
));
277 twice_word_mode
= GET_MODE_2XWIDER_MODE (word_mode
);
279 rtxes
.target
= gen_rtx_REG (word_mode
, LAST_VIRTUAL_REGISTER
+ 1);
280 rtxes
.source
= gen_rtx_REG (word_mode
, LAST_VIRTUAL_REGISTER
+ 2);
281 rtxes
.set
= gen_rtx_SET (rtxes
.target
, rtxes
.source
);
282 rtxes
.zext
= gen_rtx_ZERO_EXTEND (twice_word_mode
, rtxes
.source
);
283 rtxes
.shift
= gen_rtx_ASHIFT (twice_word_mode
, rtxes
.source
, const0_rtx
);
286 fprintf (stderr
, "\nSize costs\n==========\n\n");
287 compute_costs (false, &rtxes
);
290 fprintf (stderr
, "\nSpeed costs\n===========\n\n");
291 compute_costs (true, &rtxes
);
295 simple_move_operand (rtx x
)
297 if (GET_CODE (x
) == SUBREG
)
303 if (GET_CODE (x
) == LABEL_REF
304 || GET_CODE (x
) == SYMBOL_REF
305 || GET_CODE (x
) == HIGH
306 || GET_CODE (x
) == CONST
)
310 && (MEM_VOLATILE_P (x
)
311 || mode_dependent_address_p (XEXP (x
, 0), MEM_ADDR_SPACE (x
))))
317 /* If INSN is a single set between two objects that we want to split,
318 return the single set. SPEED_P says whether we are optimizing
319 INSN for speed or size.
321 INSN should have been passed to recog and extract_insn before this
325 simple_move (rtx_insn
*insn
, bool speed_p
)
331 if (recog_data
.n_operands
!= 2)
334 set
= single_set (insn
);
339 if (x
!= recog_data
.operand
[0] && x
!= recog_data
.operand
[1])
341 if (!simple_move_operand (x
))
345 if (x
!= recog_data
.operand
[0] && x
!= recog_data
.operand
[1])
347 /* For the src we can handle ASM_OPERANDS, and it is beneficial for
348 things like x86 rdtsc which returns a DImode value. */
349 if (GET_CODE (x
) != ASM_OPERANDS
350 && !simple_move_operand (x
))
353 /* We try to decompose in integer modes, to avoid generating
354 inefficient code copying between integer and floating point
355 registers. That means that we can't decompose if this is a
356 non-integer mode for which there is no integer mode of the same
358 mode
= GET_MODE (SET_DEST (set
));
359 if (!SCALAR_INT_MODE_P (mode
)
360 && (mode_for_size (GET_MODE_SIZE (mode
) * BITS_PER_UNIT
, MODE_INT
, 0)
364 /* Reject PARTIAL_INT modes. They are used for processor specific
365 purposes and it's probably best not to tamper with them. */
366 if (GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
369 if (!choices
[speed_p
].move_modes_to_split
[(int) mode
])
375 /* If SET is a copy from one multi-word pseudo-register to another,
376 record that in reg_copy_graph. Return whether it is such a
380 find_pseudo_copy (rtx set
)
382 rtx dest
= SET_DEST (set
);
383 rtx src
= SET_SRC (set
);
387 if (!REG_P (dest
) || !REG_P (src
))
392 if (HARD_REGISTER_NUM_P (rd
) || HARD_REGISTER_NUM_P (rs
))
395 b
= reg_copy_graph
[rs
];
398 b
= BITMAP_ALLOC (NULL
);
399 reg_copy_graph
[rs
] = b
;
402 bitmap_set_bit (b
, rd
);
407 /* Look through the registers in DECOMPOSABLE_CONTEXT. For each case
408 where they are copied to another register, add the register to
409 which they are copied to DECOMPOSABLE_CONTEXT. Use
410 NON_DECOMPOSABLE_CONTEXT to limit this--we don't bother to track
411 copies of registers which are in NON_DECOMPOSABLE_CONTEXT. */
414 propagate_pseudo_copies (void)
416 bitmap queue
, propagate
;
418 queue
= BITMAP_ALLOC (NULL
);
419 propagate
= BITMAP_ALLOC (NULL
);
421 bitmap_copy (queue
, decomposable_context
);
424 bitmap_iterator iter
;
427 bitmap_clear (propagate
);
429 EXECUTE_IF_SET_IN_BITMAP (queue
, 0, i
, iter
)
431 bitmap b
= reg_copy_graph
[i
];
433 bitmap_ior_and_compl_into (propagate
, b
, non_decomposable_context
);
436 bitmap_and_compl (queue
, propagate
, decomposable_context
);
437 bitmap_ior_into (decomposable_context
, propagate
);
439 while (!bitmap_empty_p (queue
));
442 BITMAP_FREE (propagate
);
445 /* A pointer to one of these values is passed to
446 find_decomposable_subregs. */
448 enum classify_move_insn
450 /* Not a simple move from one location to another. */
452 /* A simple move we want to decompose. */
453 DECOMPOSABLE_SIMPLE_MOVE
,
454 /* Any other simple move. */
458 /* If we find a SUBREG in *LOC which we could use to decompose a
459 pseudo-register, set a bit in DECOMPOSABLE_CONTEXT. If we find an
460 unadorned register which is not a simple pseudo-register copy,
461 DATA will point at the type of move, and we set a bit in
462 DECOMPOSABLE_CONTEXT or NON_DECOMPOSABLE_CONTEXT as appropriate. */
465 find_decomposable_subregs (rtx
*loc
, enum classify_move_insn
*pcmi
)
467 subrtx_var_iterator::array_type array
;
468 FOR_EACH_SUBRTX_VAR (iter
, array
, *loc
, NONCONST
)
471 if (GET_CODE (x
) == SUBREG
)
473 rtx inner
= SUBREG_REG (x
);
474 unsigned int regno
, outer_size
, inner_size
, outer_words
, inner_words
;
479 regno
= REGNO (inner
);
480 if (HARD_REGISTER_NUM_P (regno
))
482 iter
.skip_subrtxes ();
486 outer_size
= GET_MODE_SIZE (GET_MODE (x
));
487 inner_size
= GET_MODE_SIZE (GET_MODE (inner
));
488 outer_words
= (outer_size
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
489 inner_words
= (inner_size
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
491 /* We only try to decompose single word subregs of multi-word
492 registers. When we find one, we return -1 to avoid iterating
493 over the inner register.
495 ??? This doesn't allow, e.g., DImode subregs of TImode values
496 on 32-bit targets. We would need to record the way the
497 pseudo-register was used, and only decompose if all the uses
498 were the same number and size of pieces. Hopefully this
499 doesn't happen much. */
501 if (outer_words
== 1 && inner_words
> 1)
503 bitmap_set_bit (decomposable_context
, regno
);
504 iter
.skip_subrtxes ();
508 /* If this is a cast from one mode to another, where the modes
509 have the same size, and they are not tieable, then mark this
510 register as non-decomposable. If we decompose it we are
511 likely to mess up whatever the backend is trying to do. */
513 && outer_size
== inner_size
514 && !MODES_TIEABLE_P (GET_MODE (x
), GET_MODE (inner
)))
516 bitmap_set_bit (non_decomposable_context
, regno
);
517 bitmap_set_bit (subreg_context
, regno
);
518 iter
.skip_subrtxes ();
526 /* We will see an outer SUBREG before we see the inner REG, so
527 when we see a plain REG here it means a direct reference to
530 If this is not a simple copy from one location to another,
531 then we can not decompose this register. If this is a simple
532 copy we want to decompose, and the mode is right,
533 then we mark the register as decomposable.
534 Otherwise we don't say anything about this register --
535 it could be decomposed, but whether that would be
536 profitable depends upon how it is used elsewhere.
538 We only set bits in the bitmap for multi-word
539 pseudo-registers, since those are the only ones we care about
540 and it keeps the size of the bitmaps down. */
543 if (!HARD_REGISTER_NUM_P (regno
)
544 && GET_MODE_SIZE (GET_MODE (x
)) > UNITS_PER_WORD
)
548 case NOT_SIMPLE_MOVE
:
549 bitmap_set_bit (non_decomposable_context
, regno
);
551 case DECOMPOSABLE_SIMPLE_MOVE
:
552 if (MODES_TIEABLE_P (GET_MODE (x
), word_mode
))
553 bitmap_set_bit (decomposable_context
, regno
);
564 enum classify_move_insn cmi_mem
= NOT_SIMPLE_MOVE
;
566 /* Any registers used in a MEM do not participate in a
567 SIMPLE_MOVE or DECOMPOSABLE_SIMPLE_MOVE. Do our own recursion
568 here, and return -1 to block the parent's recursion. */
569 find_decomposable_subregs (&XEXP (x
, 0), &cmi_mem
);
570 iter
.skip_subrtxes ();
575 /* Decompose REGNO into word-sized components. We smash the REG node
576 in place. This ensures that (1) something goes wrong quickly if we
577 fail to make some replacement, and (2) the debug information inside
578 the symbol table is automatically kept up to date. */
581 decompose_register (unsigned int regno
)
584 unsigned int words
, i
;
587 reg
= regno_reg_rtx
[regno
];
589 regno_reg_rtx
[regno
] = NULL_RTX
;
591 words
= GET_MODE_SIZE (GET_MODE (reg
));
592 words
= (words
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
594 v
= rtvec_alloc (words
);
595 for (i
= 0; i
< words
; ++i
)
596 RTVEC_ELT (v
, i
) = gen_reg_rtx_offset (reg
, word_mode
, i
* UNITS_PER_WORD
);
598 PUT_CODE (reg
, CONCATN
);
603 fprintf (dump_file
, "; Splitting reg %u ->", regno
);
604 for (i
= 0; i
< words
; ++i
)
605 fprintf (dump_file
, " %u", REGNO (XVECEXP (reg
, 0, i
)));
606 fputc ('\n', dump_file
);
610 /* Get a SUBREG of a CONCATN. */
613 simplify_subreg_concatn (machine_mode outermode
, rtx op
,
616 unsigned int inner_size
;
617 machine_mode innermode
, partmode
;
619 unsigned int final_offset
;
621 gcc_assert (GET_CODE (op
) == CONCATN
);
622 gcc_assert (byte
% GET_MODE_SIZE (outermode
) == 0);
624 innermode
= GET_MODE (op
);
625 gcc_assert (byte
< GET_MODE_SIZE (innermode
));
626 gcc_assert (GET_MODE_SIZE (outermode
) <= GET_MODE_SIZE (innermode
));
628 inner_size
= GET_MODE_SIZE (innermode
) / XVECLEN (op
, 0);
629 part
= XVECEXP (op
, 0, byte
/ inner_size
);
630 partmode
= GET_MODE (part
);
632 /* VECTOR_CSTs in debug expressions are expanded into CONCATN instead of
633 regular CONST_VECTORs. They have vector or integer modes, depending
634 on the capabilities of the target. Cope with them. */
635 if (partmode
== VOIDmode
&& VECTOR_MODE_P (innermode
))
636 partmode
= GET_MODE_INNER (innermode
);
637 else if (partmode
== VOIDmode
)
639 enum mode_class mclass
= GET_MODE_CLASS (innermode
);
640 partmode
= mode_for_size (inner_size
* BITS_PER_UNIT
, mclass
, 0);
643 final_offset
= byte
% inner_size
;
644 if (final_offset
+ GET_MODE_SIZE (outermode
) > inner_size
)
647 return simplify_gen_subreg (outermode
, part
, partmode
, final_offset
);
650 /* Wrapper around simplify_gen_subreg which handles CONCATN. */
653 simplify_gen_subreg_concatn (machine_mode outermode
, rtx op
,
654 machine_mode innermode
, unsigned int byte
)
658 /* We have to handle generating a SUBREG of a SUBREG of a CONCATN.
659 If OP is a SUBREG of a CONCATN, then it must be a simple mode
660 change with the same size and offset 0, or it must extract a
661 part. We shouldn't see anything else here. */
662 if (GET_CODE (op
) == SUBREG
&& GET_CODE (SUBREG_REG (op
)) == CONCATN
)
666 if ((GET_MODE_SIZE (GET_MODE (op
))
667 == GET_MODE_SIZE (GET_MODE (SUBREG_REG (op
))))
668 && SUBREG_BYTE (op
) == 0)
669 return simplify_gen_subreg_concatn (outermode
, SUBREG_REG (op
),
670 GET_MODE (SUBREG_REG (op
)), byte
);
672 op2
= simplify_subreg_concatn (GET_MODE (op
), SUBREG_REG (op
),
676 /* We don't handle paradoxical subregs here. */
677 gcc_assert (GET_MODE_SIZE (outermode
)
678 <= GET_MODE_SIZE (GET_MODE (op
)));
679 gcc_assert (GET_MODE_SIZE (GET_MODE (op
))
680 <= GET_MODE_SIZE (GET_MODE (SUBREG_REG (op
))));
681 op2
= simplify_subreg_concatn (outermode
, SUBREG_REG (op
),
682 byte
+ SUBREG_BYTE (op
));
683 gcc_assert (op2
!= NULL_RTX
);
688 gcc_assert (op
!= NULL_RTX
);
689 gcc_assert (innermode
== GET_MODE (op
));
692 if (GET_CODE (op
) == CONCATN
)
693 return simplify_subreg_concatn (outermode
, op
, byte
);
695 ret
= simplify_gen_subreg (outermode
, op
, innermode
, byte
);
697 /* If we see an insn like (set (reg:DI) (subreg:DI (reg:SI) 0)) then
698 resolve_simple_move will ask for the high part of the paradoxical
699 subreg, which does not have a value. Just return a zero. */
701 && GET_CODE (op
) == SUBREG
702 && SUBREG_BYTE (op
) == 0
703 && (GET_MODE_SIZE (innermode
)
704 > GET_MODE_SIZE (GET_MODE (SUBREG_REG (op
)))))
705 return CONST0_RTX (outermode
);
707 gcc_assert (ret
!= NULL_RTX
);
711 /* Return whether we should resolve X into the registers into which it
715 resolve_reg_p (rtx x
)
717 return GET_CODE (x
) == CONCATN
;
720 /* Return whether X is a SUBREG of a register which we need to
724 resolve_subreg_p (rtx x
)
726 if (GET_CODE (x
) != SUBREG
)
728 return resolve_reg_p (SUBREG_REG (x
));
731 /* Look for SUBREGs in *LOC which need to be decomposed. */
734 resolve_subreg_use (rtx
*loc
, rtx insn
)
736 subrtx_ptr_iterator::array_type array
;
737 FOR_EACH_SUBRTX_PTR (iter
, array
, loc
, NONCONST
)
741 if (resolve_subreg_p (x
))
743 x
= simplify_subreg_concatn (GET_MODE (x
), SUBREG_REG (x
),
746 /* It is possible for a note to contain a reference which we can
747 decompose. In this case, return 1 to the caller to indicate
748 that the note must be removed. */
755 validate_change (insn
, loc
, x
, 1);
756 iter
.skip_subrtxes ();
758 else if (resolve_reg_p (x
))
759 /* Return 1 to the caller to indicate that we found a direct
760 reference to a register which is being decomposed. This can
761 happen inside notes, multiword shift or zero-extend
769 /* Resolve any decomposed registers which appear in register notes on
773 resolve_reg_notes (rtx_insn
*insn
)
777 note
= find_reg_equal_equiv_note (insn
);
780 int old_count
= num_validated_changes ();
781 if (resolve_subreg_use (&XEXP (note
, 0), NULL_RTX
))
782 remove_note (insn
, note
);
784 if (old_count
!= num_validated_changes ())
785 df_notes_rescan (insn
);
788 pnote
= ®_NOTES (insn
);
789 while (*pnote
!= NULL_RTX
)
794 switch (REG_NOTE_KIND (note
))
798 if (resolve_reg_p (XEXP (note
, 0)))
807 *pnote
= XEXP (note
, 1);
809 pnote
= &XEXP (note
, 1);
813 /* Return whether X can be decomposed into subwords. */
816 can_decompose_p (rtx x
)
820 unsigned int regno
= REGNO (x
);
822 if (HARD_REGISTER_NUM_P (regno
))
824 unsigned int byte
, num_bytes
;
826 num_bytes
= GET_MODE_SIZE (GET_MODE (x
));
827 for (byte
= 0; byte
< num_bytes
; byte
+= UNITS_PER_WORD
)
828 if (simplify_subreg_regno (regno
, GET_MODE (x
), byte
, word_mode
) < 0)
833 return !bitmap_bit_p (subreg_context
, regno
);
839 /* Decompose the registers used in a simple move SET within INSN. If
840 we don't change anything, return INSN, otherwise return the start
841 of the sequence of moves. */
844 resolve_simple_move (rtx set
, rtx_insn
*insn
)
846 rtx src
, dest
, real_dest
;
848 machine_mode orig_mode
, dest_mode
;
853 dest
= SET_DEST (set
);
854 orig_mode
= GET_MODE (dest
);
856 words
= (GET_MODE_SIZE (orig_mode
) + UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
857 gcc_assert (words
> 1);
861 /* We have to handle copying from a SUBREG of a decomposed reg where
862 the SUBREG is larger than word size. Rather than assume that we
863 can take a word_mode SUBREG of the destination, we copy to a new
864 register and then copy that to the destination. */
866 real_dest
= NULL_RTX
;
868 if (GET_CODE (src
) == SUBREG
869 && resolve_reg_p (SUBREG_REG (src
))
870 && (SUBREG_BYTE (src
) != 0
871 || (GET_MODE_SIZE (orig_mode
)
872 != GET_MODE_SIZE (GET_MODE (SUBREG_REG (src
))))))
875 dest
= gen_reg_rtx (orig_mode
);
876 if (REG_P (real_dest
))
877 REG_ATTRS (dest
) = REG_ATTRS (real_dest
);
880 /* Similarly if we are copying to a SUBREG of a decomposed reg where
881 the SUBREG is larger than word size. */
883 if (GET_CODE (dest
) == SUBREG
884 && resolve_reg_p (SUBREG_REG (dest
))
885 && (SUBREG_BYTE (dest
) != 0
886 || (GET_MODE_SIZE (orig_mode
)
887 != GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest
))))))
892 reg
= gen_reg_rtx (orig_mode
);
893 minsn
= emit_move_insn (reg
, src
);
894 smove
= single_set (minsn
);
895 gcc_assert (smove
!= NULL_RTX
);
896 resolve_simple_move (smove
, minsn
);
900 /* If we didn't have any big SUBREGS of decomposed registers, and
901 neither side of the move is a register we are decomposing, then
902 we don't have to do anything here. */
904 if (src
== SET_SRC (set
)
905 && dest
== SET_DEST (set
)
906 && !resolve_reg_p (src
)
907 && !resolve_subreg_p (src
)
908 && !resolve_reg_p (dest
)
909 && !resolve_subreg_p (dest
))
915 /* It's possible for the code to use a subreg of a decomposed
916 register while forming an address. We need to handle that before
917 passing the address to emit_move_insn. We pass NULL_RTX as the
918 insn parameter to resolve_subreg_use because we can not validate
920 if (MEM_P (src
) || MEM_P (dest
))
925 resolve_subreg_use (&XEXP (src
, 0), NULL_RTX
);
927 resolve_subreg_use (&XEXP (dest
, 0), NULL_RTX
);
928 acg
= apply_change_group ();
932 /* If SRC is a register which we can't decompose, or has side
933 effects, we need to move via a temporary register. */
935 if (!can_decompose_p (src
)
936 || side_effects_p (src
)
937 || GET_CODE (src
) == ASM_OPERANDS
)
941 reg
= gen_reg_rtx (orig_mode
);
945 rtx move
= emit_move_insn (reg
, src
);
948 rtx note
= find_reg_note (insn
, REG_INC
, NULL_RTX
);
950 add_reg_note (move
, REG_INC
, XEXP (note
, 0));
954 emit_move_insn (reg
, src
);
959 /* If DEST is a register which we can't decompose, or has side
960 effects, we need to first move to a temporary register. We
961 handle the common case of pushing an operand directly. We also
962 go through a temporary register if it holds a floating point
963 value. This gives us better code on systems which can't move
964 data easily between integer and floating point registers. */
966 dest_mode
= orig_mode
;
967 pushing
= push_operand (dest
, dest_mode
);
968 if (!can_decompose_p (dest
)
969 || (side_effects_p (dest
) && !pushing
)
970 || (!SCALAR_INT_MODE_P (dest_mode
)
971 && !resolve_reg_p (dest
)
972 && !resolve_subreg_p (dest
)))
974 if (real_dest
== NULL_RTX
)
976 if (!SCALAR_INT_MODE_P (dest_mode
))
978 dest_mode
= mode_for_size (GET_MODE_SIZE (dest_mode
) * BITS_PER_UNIT
,
980 gcc_assert (dest_mode
!= BLKmode
);
982 dest
= gen_reg_rtx (dest_mode
);
983 if (REG_P (real_dest
))
984 REG_ATTRS (dest
) = REG_ATTRS (real_dest
);
989 unsigned int i
, j
, jinc
;
991 gcc_assert (GET_MODE_SIZE (orig_mode
) % UNITS_PER_WORD
== 0);
992 gcc_assert (GET_CODE (XEXP (dest
, 0)) != PRE_MODIFY
);
993 gcc_assert (GET_CODE (XEXP (dest
, 0)) != POST_MODIFY
);
995 if (WORDS_BIG_ENDIAN
== STACK_GROWS_DOWNWARD
)
1006 for (i
= 0; i
< words
; ++i
, j
+= jinc
)
1010 temp
= copy_rtx (XEXP (dest
, 0));
1011 temp
= adjust_automodify_address_nv (dest
, word_mode
, temp
,
1012 j
* UNITS_PER_WORD
);
1013 emit_move_insn (temp
,
1014 simplify_gen_subreg_concatn (word_mode
, src
,
1016 j
* UNITS_PER_WORD
));
1023 if (REG_P (dest
) && !HARD_REGISTER_NUM_P (REGNO (dest
)))
1024 emit_clobber (dest
);
1026 for (i
= 0; i
< words
; ++i
)
1027 emit_move_insn (simplify_gen_subreg_concatn (word_mode
, dest
,
1029 i
* UNITS_PER_WORD
),
1030 simplify_gen_subreg_concatn (word_mode
, src
,
1032 i
* UNITS_PER_WORD
));
1035 if (real_dest
!= NULL_RTX
)
1040 if (dest_mode
== orig_mode
)
1043 mdest
= simplify_gen_subreg (orig_mode
, dest
, GET_MODE (dest
), 0);
1044 minsn
= emit_move_insn (real_dest
, mdest
);
1046 if (AUTO_INC_DEC
&& MEM_P (real_dest
)
1047 && !(resolve_reg_p (real_dest
) || resolve_subreg_p (real_dest
)))
1049 rtx note
= find_reg_note (insn
, REG_INC
, NULL_RTX
);
1051 add_reg_note (minsn
, REG_INC
, XEXP (note
, 0));
1054 smove
= single_set (minsn
);
1055 gcc_assert (smove
!= NULL_RTX
);
1057 resolve_simple_move (smove
, minsn
);
1060 insns
= get_insns ();
1063 copy_reg_eh_region_note_forward (insn
, insns
, NULL_RTX
);
1065 emit_insn_before (insns
, insn
);
1067 /* If we get here via self-recursion, then INSN is not yet in the insns
1068 chain and delete_insn will fail. We only want to remove INSN from the
1069 current sequence. See PR56738. */
1070 if (in_sequence_p ())
1078 /* Change a CLOBBER of a decomposed register into a CLOBBER of the
1079 component registers. Return whether we changed something. */
1082 resolve_clobber (rtx pat
, rtx_insn
*insn
)
1085 machine_mode orig_mode
;
1086 unsigned int words
, i
;
1089 reg
= XEXP (pat
, 0);
1090 if (!resolve_reg_p (reg
) && !resolve_subreg_p (reg
))
1093 orig_mode
= GET_MODE (reg
);
1094 words
= GET_MODE_SIZE (orig_mode
);
1095 words
= (words
+ UNITS_PER_WORD
- 1) / UNITS_PER_WORD
;
1097 ret
= validate_change (NULL_RTX
, &XEXP (pat
, 0),
1098 simplify_gen_subreg_concatn (word_mode
, reg
,
1101 df_insn_rescan (insn
);
1102 gcc_assert (ret
!= 0);
1104 for (i
= words
- 1; i
> 0; --i
)
1108 x
= simplify_gen_subreg_concatn (word_mode
, reg
, orig_mode
,
1109 i
* UNITS_PER_WORD
);
1110 x
= gen_rtx_CLOBBER (VOIDmode
, x
);
1111 emit_insn_after (x
, insn
);
1114 resolve_reg_notes (insn
);
1119 /* A USE of a decomposed register is no longer meaningful. Return
1120 whether we changed something. */
1123 resolve_use (rtx pat
, rtx_insn
*insn
)
1125 if (resolve_reg_p (XEXP (pat
, 0)) || resolve_subreg_p (XEXP (pat
, 0)))
1131 resolve_reg_notes (insn
);
1136 /* A VAR_LOCATION can be simplified. */
1139 resolve_debug (rtx_insn
*insn
)
1141 subrtx_ptr_iterator::array_type array
;
1142 FOR_EACH_SUBRTX_PTR (iter
, array
, &PATTERN (insn
), NONCONST
)
1146 if (resolve_subreg_p (x
))
1148 x
= simplify_subreg_concatn (GET_MODE (x
), SUBREG_REG (x
),
1154 x
= copy_rtx (*loc
);
1156 if (resolve_reg_p (x
))
1157 *loc
= copy_rtx (x
);
1160 df_insn_rescan (insn
);
1162 resolve_reg_notes (insn
);
1165 /* Check if INSN is a decomposable multiword-shift or zero-extend and
1166 set the decomposable_context bitmap accordingly. SPEED_P is true
1167 if we are optimizing INSN for speed rather than size. Return true
1168 if INSN is decomposable. */
1171 find_decomposable_shift_zext (rtx_insn
*insn
, bool speed_p
)
1177 set
= single_set (insn
);
1182 if (GET_CODE (op
) != ASHIFT
1183 && GET_CODE (op
) != LSHIFTRT
1184 && GET_CODE (op
) != ASHIFTRT
1185 && GET_CODE (op
) != ZERO_EXTEND
)
1188 op_operand
= XEXP (op
, 0);
1189 if (!REG_P (SET_DEST (set
)) || !REG_P (op_operand
)
1190 || HARD_REGISTER_NUM_P (REGNO (SET_DEST (set
)))
1191 || HARD_REGISTER_NUM_P (REGNO (op_operand
))
1192 || GET_MODE (op
) != twice_word_mode
)
1195 if (GET_CODE (op
) == ZERO_EXTEND
)
1197 if (GET_MODE (op_operand
) != word_mode
1198 || !choices
[speed_p
].splitting_zext
)
1201 else /* left or right shift */
1203 bool *splitting
= (GET_CODE (op
) == ASHIFT
1204 ? choices
[speed_p
].splitting_ashift
1205 : GET_CODE (op
) == ASHIFTRT
1206 ? choices
[speed_p
].splitting_ashiftrt
1207 : choices
[speed_p
].splitting_lshiftrt
);
1208 if (!CONST_INT_P (XEXP (op
, 1))
1209 || !IN_RANGE (INTVAL (XEXP (op
, 1)), BITS_PER_WORD
,
1210 2 * BITS_PER_WORD
- 1)
1211 || !splitting
[INTVAL (XEXP (op
, 1)) - BITS_PER_WORD
])
1214 bitmap_set_bit (decomposable_context
, REGNO (op_operand
));
1217 bitmap_set_bit (decomposable_context
, REGNO (SET_DEST (set
)));
1222 /* Decompose a more than word wide shift (in INSN) of a multiword
1223 pseudo or a multiword zero-extend of a wordmode pseudo into a move
1224 and 'set to zero' insn. Return a pointer to the new insn when a
1225 replacement was done. */
1228 resolve_shift_zext (rtx_insn
*insn
)
1234 rtx src_reg
, dest_reg
, dest_upper
, upper_src
= NULL_RTX
;
1235 int src_reg_num
, dest_reg_num
, offset1
, offset2
, src_offset
;
1237 set
= single_set (insn
);
1242 if (GET_CODE (op
) != ASHIFT
1243 && GET_CODE (op
) != LSHIFTRT
1244 && GET_CODE (op
) != ASHIFTRT
1245 && GET_CODE (op
) != ZERO_EXTEND
)
1248 op_operand
= XEXP (op
, 0);
1250 /* We can tear this operation apart only if the regs were already
1252 if (!resolve_reg_p (SET_DEST (set
)) && !resolve_reg_p (op_operand
))
1255 /* src_reg_num is the number of the word mode register which we
1256 are operating on. For a left shift and a zero_extend on little
1257 endian machines this is register 0. */
1258 src_reg_num
= (GET_CODE (op
) == LSHIFTRT
|| GET_CODE (op
) == ASHIFTRT
)
1261 if (WORDS_BIG_ENDIAN
1262 && GET_MODE_SIZE (GET_MODE (op_operand
)) > UNITS_PER_WORD
)
1263 src_reg_num
= 1 - src_reg_num
;
1265 if (GET_CODE (op
) == ZERO_EXTEND
)
1266 dest_reg_num
= WORDS_BIG_ENDIAN
? 1 : 0;
1268 dest_reg_num
= 1 - src_reg_num
;
1270 offset1
= UNITS_PER_WORD
* dest_reg_num
;
1271 offset2
= UNITS_PER_WORD
* (1 - dest_reg_num
);
1272 src_offset
= UNITS_PER_WORD
* src_reg_num
;
1276 dest_reg
= simplify_gen_subreg_concatn (word_mode
, SET_DEST (set
),
1277 GET_MODE (SET_DEST (set
)),
1279 dest_upper
= simplify_gen_subreg_concatn (word_mode
, SET_DEST (set
),
1280 GET_MODE (SET_DEST (set
)),
1282 src_reg
= simplify_gen_subreg_concatn (word_mode
, op_operand
,
1283 GET_MODE (op_operand
),
1285 if (GET_CODE (op
) == ASHIFTRT
1286 && INTVAL (XEXP (op
, 1)) != 2 * BITS_PER_WORD
- 1)
1287 upper_src
= expand_shift (RSHIFT_EXPR
, word_mode
, copy_rtx (src_reg
),
1288 BITS_PER_WORD
- 1, NULL_RTX
, 0);
1290 if (GET_CODE (op
) != ZERO_EXTEND
)
1292 int shift_count
= INTVAL (XEXP (op
, 1));
1293 if (shift_count
> BITS_PER_WORD
)
1294 src_reg
= expand_shift (GET_CODE (op
) == ASHIFT
?
1295 LSHIFT_EXPR
: RSHIFT_EXPR
,
1297 shift_count
- BITS_PER_WORD
,
1298 dest_reg
, GET_CODE (op
) != ASHIFTRT
);
1301 if (dest_reg
!= src_reg
)
1302 emit_move_insn (dest_reg
, src_reg
);
1303 if (GET_CODE (op
) != ASHIFTRT
)
1304 emit_move_insn (dest_upper
, CONST0_RTX (word_mode
));
1305 else if (INTVAL (XEXP (op
, 1)) == 2 * BITS_PER_WORD
- 1)
1306 emit_move_insn (dest_upper
, copy_rtx (src_reg
));
1308 emit_move_insn (dest_upper
, upper_src
);
1309 insns
= get_insns ();
1313 emit_insn_before (insns
, insn
);
1318 fprintf (dump_file
, "; Replacing insn: %d with insns: ", INSN_UID (insn
));
1319 for (in
= insns
; in
!= insn
; in
= NEXT_INSN (in
))
1320 fprintf (dump_file
, "%d ", INSN_UID (in
));
1321 fprintf (dump_file
, "\n");
1328 /* Print to dump_file a description of what we're doing with shift code CODE.
1329 SPLITTING[X] is true if we are splitting shifts by X + BITS_PER_WORD. */
1332 dump_shift_choices (enum rtx_code code
, bool *splitting
)
1338 " Splitting mode %s for %s lowering with shift amounts = ",
1339 GET_MODE_NAME (twice_word_mode
), GET_RTX_NAME (code
));
1341 for (i
= 0; i
< BITS_PER_WORD
; i
++)
1344 fprintf (dump_file
, "%s%d", sep
, i
+ BITS_PER_WORD
);
1347 fprintf (dump_file
, "\n");
1350 /* Print to dump_file a description of what we're doing when optimizing
1351 for speed or size; SPEED_P says which. DESCRIPTION is a description
1352 of the SPEED_P choice. */
1355 dump_choices (bool speed_p
, const char *description
)
1359 fprintf (dump_file
, "Choices when optimizing for %s:\n", description
);
1361 for (i
= 0; i
< MAX_MACHINE_MODE
; i
++)
1362 if (GET_MODE_SIZE ((machine_mode
) i
) > UNITS_PER_WORD
)
1363 fprintf (dump_file
, " %s mode %s for copy lowering.\n",
1364 choices
[speed_p
].move_modes_to_split
[i
]
1367 GET_MODE_NAME ((machine_mode
) i
));
1369 fprintf (dump_file
, " %s mode %s for zero_extend lowering.\n",
1370 choices
[speed_p
].splitting_zext
? "Splitting" : "Skipping",
1371 GET_MODE_NAME (twice_word_mode
));
1373 dump_shift_choices (ASHIFT
, choices
[speed_p
].splitting_ashift
);
1374 dump_shift_choices (LSHIFTRT
, choices
[speed_p
].splitting_lshiftrt
);
1375 dump_shift_choices (ASHIFTRT
, choices
[speed_p
].splitting_ashiftrt
);
1376 fprintf (dump_file
, "\n");
1379 /* Look for registers which are always accessed via word-sized SUBREGs
1380 or -if DECOMPOSE_COPIES is true- via copies. Decompose these
1381 registers into several word-sized pseudo-registers. */
1384 decompose_multiword_subregs (bool decompose_copies
)
1392 dump_choices (false, "size");
1393 dump_choices (true, "speed");
1396 /* Check if this target even has any modes to consider lowering. */
1397 if (!choices
[false].something_to_do
&& !choices
[true].something_to_do
)
1400 fprintf (dump_file
, "Nothing to do!\n");
1404 max
= max_reg_num ();
1406 /* First see if there are any multi-word pseudo-registers. If there
1407 aren't, there is nothing we can do. This should speed up this
1408 pass in the normal case, since it should be faster than scanning
1412 bool useful_modes_seen
= false;
1414 for (i
= FIRST_PSEUDO_REGISTER
; i
< max
; ++i
)
1415 if (regno_reg_rtx
[i
] != NULL
)
1417 machine_mode mode
= GET_MODE (regno_reg_rtx
[i
]);
1418 if (choices
[false].move_modes_to_split
[(int) mode
]
1419 || choices
[true].move_modes_to_split
[(int) mode
])
1421 useful_modes_seen
= true;
1426 if (!useful_modes_seen
)
1429 fprintf (dump_file
, "Nothing to lower in this function.\n");
1436 df_set_flags (DF_DEFER_INSN_RESCAN
);
1440 /* FIXME: It may be possible to change this code to look for each
1441 multi-word pseudo-register and to find each insn which sets or
1442 uses that register. That should be faster than scanning all the
1445 decomposable_context
= BITMAP_ALLOC (NULL
);
1446 non_decomposable_context
= BITMAP_ALLOC (NULL
);
1447 subreg_context
= BITMAP_ALLOC (NULL
);
1449 reg_copy_graph
.create (max
);
1450 reg_copy_graph
.safe_grow_cleared (max
);
1451 memset (reg_copy_graph
.address (), 0, sizeof (bitmap
) * max
);
1453 speed_p
= optimize_function_for_speed_p (cfun
);
1454 FOR_EACH_BB_FN (bb
, cfun
)
1458 FOR_BB_INSNS (bb
, insn
)
1461 enum classify_move_insn cmi
;
1465 || GET_CODE (PATTERN (insn
)) == CLOBBER
1466 || GET_CODE (PATTERN (insn
)) == USE
)
1469 recog_memoized (insn
);
1471 if (find_decomposable_shift_zext (insn
, speed_p
))
1474 extract_insn (insn
);
1476 set
= simple_move (insn
, speed_p
);
1479 cmi
= NOT_SIMPLE_MOVE
;
1482 /* We mark pseudo-to-pseudo copies as decomposable during the
1483 second pass only. The first pass is so early that there is
1484 good chance such moves will be optimized away completely by
1485 subsequent optimizations anyway.
1487 However, we call find_pseudo_copy even during the first pass
1488 so as to properly set up the reg_copy_graph. */
1489 if (find_pseudo_copy (set
))
1490 cmi
= decompose_copies
? DECOMPOSABLE_SIMPLE_MOVE
: SIMPLE_MOVE
;
1495 n
= recog_data
.n_operands
;
1496 for (i
= 0; i
< n
; ++i
)
1498 find_decomposable_subregs (&recog_data
.operand
[i
], &cmi
);
1500 /* We handle ASM_OPERANDS as a special case to support
1501 things like x86 rdtsc which returns a DImode value.
1502 We can decompose the output, which will certainly be
1503 operand 0, but not the inputs. */
1505 if (cmi
== SIMPLE_MOVE
1506 && GET_CODE (SET_SRC (set
)) == ASM_OPERANDS
)
1508 gcc_assert (i
== 0);
1509 cmi
= NOT_SIMPLE_MOVE
;
1515 bitmap_and_compl_into (decomposable_context
, non_decomposable_context
);
1516 if (!bitmap_empty_p (decomposable_context
))
1520 sbitmap_iterator sbi
;
1521 bitmap_iterator iter
;
1524 propagate_pseudo_copies ();
1526 sub_blocks
= sbitmap_alloc (last_basic_block_for_fn (cfun
));
1527 bitmap_clear (sub_blocks
);
1529 EXECUTE_IF_SET_IN_BITMAP (decomposable_context
, 0, regno
, iter
)
1530 decompose_register (regno
);
1532 FOR_EACH_BB_FN (bb
, cfun
)
1536 FOR_BB_INSNS (bb
, insn
)
1543 pat
= PATTERN (insn
);
1544 if (GET_CODE (pat
) == CLOBBER
)
1545 resolve_clobber (pat
, insn
);
1546 else if (GET_CODE (pat
) == USE
)
1547 resolve_use (pat
, insn
);
1548 else if (DEBUG_INSN_P (insn
))
1549 resolve_debug (insn
);
1555 recog_memoized (insn
);
1556 extract_insn (insn
);
1558 set
= simple_move (insn
, speed_p
);
1561 rtx_insn
*orig_insn
= insn
;
1562 bool cfi
= control_flow_insn_p (insn
);
1564 /* We can end up splitting loads to multi-word pseudos
1565 into separate loads to machine word size pseudos.
1566 When this happens, we first had one load that can
1567 throw, and after resolve_simple_move we'll have a
1568 bunch of loads (at least two). All those loads may
1569 trap if we can have non-call exceptions, so they
1570 all will end the current basic block. We split the
1571 block after the outer loop over all insns, but we
1572 make sure here that we will be able to split the
1573 basic block and still produce the correct control
1574 flow graph for it. */
1576 || (cfun
->can_throw_non_call_exceptions
1577 && can_throw_internal (insn
)));
1579 insn
= resolve_simple_move (set
, insn
);
1580 if (insn
!= orig_insn
)
1582 recog_memoized (insn
);
1583 extract_insn (insn
);
1586 bitmap_set_bit (sub_blocks
, bb
->index
);
1591 rtx_insn
*decomposed_shift
;
1593 decomposed_shift
= resolve_shift_zext (insn
);
1594 if (decomposed_shift
!= NULL_RTX
)
1596 insn
= decomposed_shift
;
1597 recog_memoized (insn
);
1598 extract_insn (insn
);
1602 for (i
= recog_data
.n_operands
- 1; i
>= 0; --i
)
1603 resolve_subreg_use (recog_data
.operand_loc
[i
], insn
);
1605 resolve_reg_notes (insn
);
1607 if (num_validated_changes () > 0)
1609 for (i
= recog_data
.n_dups
- 1; i
>= 0; --i
)
1611 rtx
*pl
= recog_data
.dup_loc
[i
];
1612 int dup_num
= recog_data
.dup_num
[i
];
1613 rtx
*px
= recog_data
.operand_loc
[dup_num
];
1615 validate_unshare_change (insn
, pl
, *px
, 1);
1618 i
= apply_change_group ();
1625 /* If we had insns to split that caused control flow insns in the middle
1626 of a basic block, split those blocks now. Note that we only handle
1627 the case where splitting a load has caused multiple possibly trapping
1629 EXECUTE_IF_SET_IN_BITMAP (sub_blocks
, 0, i
, sbi
)
1631 rtx_insn
*insn
, *end
;
1634 bb
= BASIC_BLOCK_FOR_FN (cfun
, i
);
1635 insn
= BB_HEAD (bb
);
1640 if (control_flow_insn_p (insn
))
1642 /* Split the block after insn. There will be a fallthru
1643 edge, which is OK so we keep it. We have to create the
1644 exception edges ourselves. */
1645 fallthru
= split_block (bb
, insn
);
1646 rtl_make_eh_edge (NULL
, bb
, BB_END (bb
));
1647 bb
= fallthru
->dest
;
1648 insn
= BB_HEAD (bb
);
1651 insn
= NEXT_INSN (insn
);
1655 sbitmap_free (sub_blocks
);
1662 FOR_EACH_VEC_ELT (reg_copy_graph
, i
, b
)
1667 reg_copy_graph
.release ();
1669 BITMAP_FREE (decomposable_context
);
1670 BITMAP_FREE (non_decomposable_context
);
1671 BITMAP_FREE (subreg_context
);
1674 /* Implement first lower subreg pass. */
1678 const pass_data pass_data_lower_subreg
=
1680 RTL_PASS
, /* type */
1681 "subreg1", /* name */
1682 OPTGROUP_NONE
, /* optinfo_flags */
1683 TV_LOWER_SUBREG
, /* tv_id */
1684 0, /* properties_required */
1685 0, /* properties_provided */
1686 0, /* properties_destroyed */
1687 0, /* todo_flags_start */
1688 0, /* todo_flags_finish */
1691 class pass_lower_subreg
: public rtl_opt_pass
1694 pass_lower_subreg (gcc::context
*ctxt
)
1695 : rtl_opt_pass (pass_data_lower_subreg
, ctxt
)
1698 /* opt_pass methods: */
1699 virtual bool gate (function
*) { return flag_split_wide_types
!= 0; }
1700 virtual unsigned int execute (function
*)
1702 decompose_multiword_subregs (false);
1706 }; // class pass_lower_subreg
1711 make_pass_lower_subreg (gcc::context
*ctxt
)
1713 return new pass_lower_subreg (ctxt
);
1716 /* Implement second lower subreg pass. */
1720 const pass_data pass_data_lower_subreg2
=
1722 RTL_PASS
, /* type */
1723 "subreg2", /* name */
1724 OPTGROUP_NONE
, /* optinfo_flags */
1725 TV_LOWER_SUBREG
, /* tv_id */
1726 0, /* properties_required */
1727 0, /* properties_provided */
1728 0, /* properties_destroyed */
1729 0, /* todo_flags_start */
1730 TODO_df_finish
, /* todo_flags_finish */
1733 class pass_lower_subreg2
: public rtl_opt_pass
1736 pass_lower_subreg2 (gcc::context
*ctxt
)
1737 : rtl_opt_pass (pass_data_lower_subreg2
, ctxt
)
1740 /* opt_pass methods: */
1741 virtual bool gate (function
*) { return flag_split_wide_types
!= 0; }
1742 virtual unsigned int execute (function
*)
1744 decompose_multiword_subregs (true);
1748 }; // class pass_lower_subreg2
1753 make_pass_lower_subreg2 (gcc::context
*ctxt
)
1755 return new pass_lower_subreg2 (ctxt
);