1 /* Decompose multiword subregs.
2 Copyright (C) 2007-2017 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"
40 #include "tree-pass.h"
41 #include "lower-subreg.h"
46 /* Decompose multi-word pseudo-registers into individual
47 pseudo-registers when possible and profitable. This is possible
48 when all the uses of a multi-word register are via SUBREG, or are
49 copies of the register to another location. Breaking apart the
50 register permits more CSE and permits better register allocation.
51 This is profitable if the machine does not have move instructions
54 This pass only splits moves with modes that are wider than
55 word_mode and ASHIFTs, LSHIFTRTs, ASHIFTRTs and ZERO_EXTENDs with
56 integer modes that are twice the width of word_mode. The latter
57 could be generalized if there was a need to do this, but the trend in
58 architectures is to not need this.
60 There are two useful preprocessor defines for use by maintainers:
64 if you wish to see the actual cost estimates that are being used
65 for each mode wider than word mode and the cost estimates for zero
66 extension and the shifts. This can be useful when port maintainers
67 are tuning insn rtx costs.
69 #define FORCE_LOWERING 1
71 if you wish to test the pass with all the transformation forced on.
72 This can be useful for finding bugs in the transformations. */
75 #define FORCE_LOWERING 0
77 /* Bit N in this bitmap is set if regno N is used in a context in
78 which we can decompose it. */
79 static bitmap decomposable_context
;
81 /* Bit N in this bitmap is set if regno N is used in a context in
82 which it can not be decomposed. */
83 static bitmap non_decomposable_context
;
85 /* Bit N in this bitmap is set if regno N is used in a subreg
86 which changes the mode but not the size. This typically happens
87 when the register accessed as a floating-point value; we want to
88 avoid generating accesses to its subwords in integer modes. */
89 static bitmap subreg_context
;
91 /* Bit N in the bitmap in element M of this array is set if there is a
92 copy from reg M to reg N. */
93 static vec
<bitmap
> reg_copy_graph
;
95 struct target_lower_subreg default_target_lower_subreg
;
97 struct target_lower_subreg
*this_target_lower_subreg
98 = &default_target_lower_subreg
;
101 #define twice_word_mode \
102 this_target_lower_subreg->x_twice_word_mode
104 this_target_lower_subreg->x_choices
106 /* Return true if MODE is a mode we know how to lower. When returning true,
107 store its byte size in *BYTES and its word size in *WORDS. */
110 interesting_mode_p (machine_mode mode
, unsigned int *bytes
,
113 *bytes
= GET_MODE_SIZE (mode
);
114 *words
= CEIL (*bytes
, UNITS_PER_WORD
);
118 /* RTXes used while computing costs. */
120 /* Source and target registers. */
124 /* A twice_word_mode ZERO_EXTEND of SOURCE. */
127 /* A shift of SOURCE. */
130 /* A SET of TARGET. */
134 /* Return the cost of a CODE shift in mode MODE by OP1 bits, using the
135 rtxes in RTXES. SPEED_P selects between the speed and size cost. */
138 shift_cost (bool speed_p
, struct cost_rtxes
*rtxes
, enum rtx_code code
,
139 machine_mode mode
, int op1
)
141 PUT_CODE (rtxes
->shift
, code
);
142 PUT_MODE (rtxes
->shift
, mode
);
143 PUT_MODE (rtxes
->source
, mode
);
144 XEXP (rtxes
->shift
, 1) = gen_int_shift_amount (mode
, op1
);
145 return set_src_cost (rtxes
->shift
, mode
, speed_p
);
148 /* For each X in the range [0, BITS_PER_WORD), set SPLITTING[X]
149 to true if it is profitable to split a double-word CODE shift
150 of X + BITS_PER_WORD bits. SPEED_P says whether we are testing
151 for speed or size profitability.
153 Use the rtxes in RTXES to calculate costs. WORD_MOVE_ZERO_COST is
154 the cost of moving zero into a word-mode register. WORD_MOVE_COST
155 is the cost of moving between word registers. */
158 compute_splitting_shift (bool speed_p
, struct cost_rtxes
*rtxes
,
159 bool *splitting
, enum rtx_code code
,
160 int word_move_zero_cost
, int word_move_cost
)
162 int wide_cost
, narrow_cost
, upper_cost
, i
;
164 for (i
= 0; i
< BITS_PER_WORD
; i
++)
166 wide_cost
= shift_cost (speed_p
, rtxes
, code
, twice_word_mode
,
169 narrow_cost
= word_move_cost
;
171 narrow_cost
= shift_cost (speed_p
, rtxes
, code
, word_mode
, i
);
173 if (code
!= ASHIFTRT
)
174 upper_cost
= word_move_zero_cost
;
175 else if (i
== BITS_PER_WORD
- 1)
176 upper_cost
= word_move_cost
;
178 upper_cost
= shift_cost (speed_p
, rtxes
, code
, word_mode
,
182 fprintf (stderr
, "%s %s by %d: original cost %d, split cost %d + %d\n",
183 GET_MODE_NAME (twice_word_mode
), GET_RTX_NAME (code
),
184 i
+ BITS_PER_WORD
, wide_cost
, narrow_cost
, upper_cost
);
186 if (FORCE_LOWERING
|| wide_cost
>= narrow_cost
+ upper_cost
)
191 /* Compute what we should do when optimizing for speed or size; SPEED_P
192 selects which. Use RTXES for computing costs. */
195 compute_costs (bool speed_p
, struct cost_rtxes
*rtxes
)
198 int word_move_zero_cost
, word_move_cost
;
200 PUT_MODE (rtxes
->target
, word_mode
);
201 SET_SRC (rtxes
->set
) = CONST0_RTX (word_mode
);
202 word_move_zero_cost
= set_rtx_cost (rtxes
->set
, speed_p
);
204 SET_SRC (rtxes
->set
) = rtxes
->source
;
205 word_move_cost
= set_rtx_cost (rtxes
->set
, speed_p
);
208 fprintf (stderr
, "%s move: from zero cost %d, from reg cost %d\n",
209 GET_MODE_NAME (word_mode
), word_move_zero_cost
, word_move_cost
);
211 for (i
= 0; i
< MAX_MACHINE_MODE
; i
++)
213 machine_mode mode
= (machine_mode
) i
;
214 unsigned int size
, factor
;
215 if (interesting_mode_p (mode
, &size
, &factor
) && factor
> 1)
217 unsigned int mode_move_cost
;
219 PUT_MODE (rtxes
->target
, mode
);
220 PUT_MODE (rtxes
->source
, mode
);
221 mode_move_cost
= set_rtx_cost (rtxes
->set
, speed_p
);
224 fprintf (stderr
, "%s move: original cost %d, split cost %d * %d\n",
225 GET_MODE_NAME (mode
), mode_move_cost
,
226 word_move_cost
, factor
);
228 if (FORCE_LOWERING
|| mode_move_cost
>= word_move_cost
* factor
)
230 choices
[speed_p
].move_modes_to_split
[i
] = true;
231 choices
[speed_p
].something_to_do
= true;
236 /* For the moves and shifts, the only case that is checked is one
237 where the mode of the target is an integer mode twice the width
240 If it is not profitable to split a double word move then do not
241 even consider the shifts or the zero extension. */
242 if (choices
[speed_p
].move_modes_to_split
[(int) twice_word_mode
])
246 /* The only case here to check to see if moving the upper part with a
247 zero is cheaper than doing the zext itself. */
248 PUT_MODE (rtxes
->source
, word_mode
);
249 zext_cost
= set_src_cost (rtxes
->zext
, twice_word_mode
, speed_p
);
252 fprintf (stderr
, "%s %s: original cost %d, split cost %d + %d\n",
253 GET_MODE_NAME (twice_word_mode
), GET_RTX_NAME (ZERO_EXTEND
),
254 zext_cost
, word_move_cost
, word_move_zero_cost
);
256 if (FORCE_LOWERING
|| zext_cost
>= word_move_cost
+ word_move_zero_cost
)
257 choices
[speed_p
].splitting_zext
= true;
259 compute_splitting_shift (speed_p
, rtxes
,
260 choices
[speed_p
].splitting_ashift
, ASHIFT
,
261 word_move_zero_cost
, word_move_cost
);
262 compute_splitting_shift (speed_p
, rtxes
,
263 choices
[speed_p
].splitting_lshiftrt
, LSHIFTRT
,
264 word_move_zero_cost
, word_move_cost
);
265 compute_splitting_shift (speed_p
, rtxes
,
266 choices
[speed_p
].splitting_ashiftrt
, ASHIFTRT
,
267 word_move_zero_cost
, word_move_cost
);
271 /* Do one-per-target initialisation. This involves determining
272 which operations on the machine are profitable. If none are found,
273 then the pass just returns when called. */
276 init_lower_subreg (void)
278 struct cost_rtxes rtxes
;
280 memset (this_target_lower_subreg
, 0, sizeof (*this_target_lower_subreg
));
282 twice_word_mode
= GET_MODE_2XWIDER_MODE (word_mode
).require ();
284 rtxes
.target
= gen_rtx_REG (word_mode
, LAST_VIRTUAL_REGISTER
+ 1);
285 rtxes
.source
= gen_rtx_REG (word_mode
, LAST_VIRTUAL_REGISTER
+ 2);
286 rtxes
.set
= gen_rtx_SET (rtxes
.target
, rtxes
.source
);
287 rtxes
.zext
= gen_rtx_ZERO_EXTEND (twice_word_mode
, rtxes
.source
);
288 rtxes
.shift
= gen_rtx_ASHIFT (twice_word_mode
, rtxes
.source
, const0_rtx
);
291 fprintf (stderr
, "\nSize costs\n==========\n\n");
292 compute_costs (false, &rtxes
);
295 fprintf (stderr
, "\nSpeed costs\n===========\n\n");
296 compute_costs (true, &rtxes
);
300 simple_move_operand (rtx x
)
302 if (GET_CODE (x
) == SUBREG
)
308 if (GET_CODE (x
) == LABEL_REF
309 || GET_CODE (x
) == SYMBOL_REF
310 || GET_CODE (x
) == HIGH
311 || GET_CODE (x
) == CONST
)
315 && (MEM_VOLATILE_P (x
)
316 || mode_dependent_address_p (XEXP (x
, 0), MEM_ADDR_SPACE (x
))))
322 /* If INSN is a single set between two objects that we want to split,
323 return the single set. SPEED_P says whether we are optimizing
324 INSN for speed or size.
326 INSN should have been passed to recog and extract_insn before this
330 simple_move (rtx_insn
*insn
, bool speed_p
)
336 if (recog_data
.n_operands
!= 2)
339 set
= single_set (insn
);
344 if (x
!= recog_data
.operand
[0] && x
!= recog_data
.operand
[1])
346 if (!simple_move_operand (x
))
350 if (x
!= recog_data
.operand
[0] && x
!= recog_data
.operand
[1])
352 /* For the src we can handle ASM_OPERANDS, and it is beneficial for
353 things like x86 rdtsc which returns a DImode value. */
354 if (GET_CODE (x
) != ASM_OPERANDS
355 && !simple_move_operand (x
))
358 /* We try to decompose in integer modes, to avoid generating
359 inefficient code copying between integer and floating point
360 registers. That means that we can't decompose if this is a
361 non-integer mode for which there is no integer mode of the same
363 mode
= GET_MODE (SET_DEST (set
));
364 if (!SCALAR_INT_MODE_P (mode
)
365 && !int_mode_for_size (GET_MODE_BITSIZE (mode
), 0).exists ())
368 /* Reject PARTIAL_INT modes. They are used for processor specific
369 purposes and it's probably best not to tamper with them. */
370 if (GET_MODE_CLASS (mode
) == MODE_PARTIAL_INT
)
373 if (!choices
[speed_p
].move_modes_to_split
[(int) mode
])
379 /* If SET is a copy from one multi-word pseudo-register to another,
380 record that in reg_copy_graph. Return whether it is such a
384 find_pseudo_copy (rtx set
)
386 rtx dest
= SET_DEST (set
);
387 rtx src
= SET_SRC (set
);
391 if (!REG_P (dest
) || !REG_P (src
))
396 if (HARD_REGISTER_NUM_P (rd
) || HARD_REGISTER_NUM_P (rs
))
399 b
= reg_copy_graph
[rs
];
402 b
= BITMAP_ALLOC (NULL
);
403 reg_copy_graph
[rs
] = b
;
406 bitmap_set_bit (b
, rd
);
411 /* Look through the registers in DECOMPOSABLE_CONTEXT. For each case
412 where they are copied to another register, add the register to
413 which they are copied to DECOMPOSABLE_CONTEXT. Use
414 NON_DECOMPOSABLE_CONTEXT to limit this--we don't bother to track
415 copies of registers which are in NON_DECOMPOSABLE_CONTEXT. */
418 propagate_pseudo_copies (void)
420 auto_bitmap queue
, propagate
;
422 bitmap_copy (queue
, decomposable_context
);
425 bitmap_iterator iter
;
428 bitmap_clear (propagate
);
430 EXECUTE_IF_SET_IN_BITMAP (queue
, 0, i
, iter
)
432 bitmap b
= reg_copy_graph
[i
];
434 bitmap_ior_and_compl_into (propagate
, b
, non_decomposable_context
);
437 bitmap_and_compl (queue
, propagate
, decomposable_context
);
438 bitmap_ior_into (decomposable_context
, propagate
);
440 while (!bitmap_empty_p (queue
));
443 /* A pointer to one of these values is passed to
444 find_decomposable_subregs. */
446 enum classify_move_insn
448 /* Not a simple move from one location to another. */
450 /* A simple move we want to decompose. */
451 DECOMPOSABLE_SIMPLE_MOVE
,
452 /* Any other simple move. */
456 /* If we find a SUBREG in *LOC which we could use to decompose a
457 pseudo-register, set a bit in DECOMPOSABLE_CONTEXT. If we find an
458 unadorned register which is not a simple pseudo-register copy,
459 DATA will point at the type of move, and we set a bit in
460 DECOMPOSABLE_CONTEXT or NON_DECOMPOSABLE_CONTEXT as appropriate. */
463 find_decomposable_subregs (rtx
*loc
, enum classify_move_insn
*pcmi
)
465 subrtx_var_iterator::array_type array
;
466 FOR_EACH_SUBRTX_VAR (iter
, array
, *loc
, NONCONST
)
469 if (GET_CODE (x
) == SUBREG
)
471 rtx inner
= SUBREG_REG (x
);
472 unsigned int regno
, outer_size
, inner_size
, outer_words
, inner_words
;
477 regno
= REGNO (inner
);
478 if (HARD_REGISTER_NUM_P (regno
))
480 iter
.skip_subrtxes ();
484 if (!interesting_mode_p (GET_MODE (x
), &outer_size
, &outer_words
)
485 || !interesting_mode_p (GET_MODE (inner
), &inner_size
,
489 /* We only try to decompose single word subregs of multi-word
490 registers. When we find one, we return -1 to avoid iterating
491 over the inner register.
493 ??? This doesn't allow, e.g., DImode subregs of TImode values
494 on 32-bit targets. We would need to record the way the
495 pseudo-register was used, and only decompose if all the uses
496 were the same number and size of pieces. Hopefully this
497 doesn't happen much. */
499 if (outer_words
== 1 && inner_words
> 1)
501 bitmap_set_bit (decomposable_context
, regno
);
502 iter
.skip_subrtxes ();
506 /* If this is a cast from one mode to another, where the modes
507 have the same size, and they are not tieable, then mark this
508 register as non-decomposable. If we decompose it we are
509 likely to mess up whatever the backend is trying to do. */
511 && outer_size
== inner_size
512 && !targetm
.modes_tieable_p (GET_MODE (x
), GET_MODE (inner
)))
514 bitmap_set_bit (non_decomposable_context
, regno
);
515 bitmap_set_bit (subreg_context
, regno
);
516 iter
.skip_subrtxes ();
522 unsigned int regno
, size
, words
;
524 /* We will see an outer SUBREG before we see the inner REG, so
525 when we see a plain REG here it means a direct reference to
528 If this is not a simple copy from one location to another,
529 then we can not decompose this register. If this is a simple
530 copy we want to decompose, and the mode is right,
531 then we mark the register as decomposable.
532 Otherwise we don't say anything about this register --
533 it could be decomposed, but whether that would be
534 profitable depends upon how it is used elsewhere.
536 We only set bits in the bitmap for multi-word
537 pseudo-registers, since those are the only ones we care about
538 and it keeps the size of the bitmaps down. */
541 if (!HARD_REGISTER_NUM_P (regno
)
542 && interesting_mode_p (GET_MODE (x
), &size
, &words
)
547 case NOT_SIMPLE_MOVE
:
548 bitmap_set_bit (non_decomposable_context
, regno
);
550 case DECOMPOSABLE_SIMPLE_MOVE
:
551 if (targetm
.modes_tieable_p (GET_MODE (x
), word_mode
))
552 bitmap_set_bit (decomposable_context
, regno
);
563 enum classify_move_insn cmi_mem
= NOT_SIMPLE_MOVE
;
565 /* Any registers used in a MEM do not participate in a
566 SIMPLE_MOVE or DECOMPOSABLE_SIMPLE_MOVE. Do our own recursion
567 here, and return -1 to block the parent's recursion. */
568 find_decomposable_subregs (&XEXP (x
, 0), &cmi_mem
);
569 iter
.skip_subrtxes ();
574 /* Decompose REGNO into word-sized components. We smash the REG node
575 in place. This ensures that (1) something goes wrong quickly if we
576 fail to make some replacement, and (2) the debug information inside
577 the symbol table is automatically kept up to date. */
580 decompose_register (unsigned int regno
)
583 unsigned int size
, words
, i
;
586 reg
= regno_reg_rtx
[regno
];
588 regno_reg_rtx
[regno
] = NULL_RTX
;
590 if (!interesting_mode_p (GET_MODE (reg
), &size
, &words
))
593 v
= rtvec_alloc (words
);
594 for (i
= 0; i
< words
; ++i
)
595 RTVEC_ELT (v
, i
) = gen_reg_rtx_offset (reg
, word_mode
, i
* UNITS_PER_WORD
);
597 PUT_CODE (reg
, CONCATN
);
602 fprintf (dump_file
, "; Splitting reg %u ->", regno
);
603 for (i
= 0; i
< words
; ++i
)
604 fprintf (dump_file
, " %u", REGNO (XVECEXP (reg
, 0, i
)));
605 fputc ('\n', dump_file
);
609 /* Get a SUBREG of a CONCATN. */
612 simplify_subreg_concatn (machine_mode outermode
, rtx op
, poly_uint64 orig_byte
)
614 unsigned int outer_size
, outer_words
, inner_size
, inner_words
;
615 machine_mode innermode
, partmode
;
617 unsigned int final_offset
;
620 innermode
= GET_MODE (op
);
621 if (!interesting_mode_p (outermode
, &outer_size
, &outer_words
)
622 || !interesting_mode_p (innermode
, &inner_size
, &inner_words
))
625 /* Must be constant if interesting_mode_p passes. */
626 byte
= orig_byte
.to_constant ();
627 gcc_assert (GET_CODE (op
) == CONCATN
);
628 gcc_assert (byte
% outer_size
== 0);
630 gcc_assert (byte
< inner_size
);
631 if (outer_size
> inner_size
)
634 inner_size
/= XVECLEN (op
, 0);
635 part
= XVECEXP (op
, 0, byte
/ inner_size
);
636 partmode
= GET_MODE (part
);
638 final_offset
= byte
% inner_size
;
639 if (final_offset
+ outer_size
> inner_size
)
642 /* VECTOR_CSTs in debug expressions are expanded into CONCATN instead of
643 regular CONST_VECTORs. They have vector or integer modes, depending
644 on the capabilities of the target. Cope with them. */
645 if (partmode
== VOIDmode
&& VECTOR_MODE_P (innermode
))
646 partmode
= GET_MODE_INNER (innermode
);
647 else if (partmode
== VOIDmode
)
648 partmode
= mode_for_size (inner_size
* BITS_PER_UNIT
,
649 GET_MODE_CLASS (innermode
), 0).require ();
651 return simplify_gen_subreg (outermode
, part
, partmode
, final_offset
);
654 /* Wrapper around simplify_gen_subreg which handles CONCATN. */
657 simplify_gen_subreg_concatn (machine_mode outermode
, rtx op
,
658 machine_mode innermode
, unsigned int byte
)
662 /* We have to handle generating a SUBREG of a SUBREG of a CONCATN.
663 If OP is a SUBREG of a CONCATN, then it must be a simple mode
664 change with the same size and offset 0, or it must extract a
665 part. We shouldn't see anything else here. */
666 if (GET_CODE (op
) == SUBREG
&& GET_CODE (SUBREG_REG (op
)) == CONCATN
)
670 if ((GET_MODE_SIZE (GET_MODE (op
))
671 == GET_MODE_SIZE (GET_MODE (SUBREG_REG (op
))))
672 && known_eq (SUBREG_BYTE (op
), 0))
673 return simplify_gen_subreg_concatn (outermode
, SUBREG_REG (op
),
674 GET_MODE (SUBREG_REG (op
)), byte
);
676 op2
= simplify_subreg_concatn (GET_MODE (op
), SUBREG_REG (op
),
680 /* We don't handle paradoxical subregs here. */
681 gcc_assert (!paradoxical_subreg_p (outermode
, GET_MODE (op
)));
682 gcc_assert (!paradoxical_subreg_p (op
));
683 op2
= simplify_subreg_concatn (outermode
, SUBREG_REG (op
),
684 byte
+ SUBREG_BYTE (op
));
685 gcc_assert (op2
!= NULL_RTX
);
690 gcc_assert (op
!= NULL_RTX
);
691 gcc_assert (innermode
== GET_MODE (op
));
694 if (GET_CODE (op
) == CONCATN
)
695 return simplify_subreg_concatn (outermode
, op
, byte
);
697 ret
= simplify_gen_subreg (outermode
, op
, innermode
, byte
);
699 /* If we see an insn like (set (reg:DI) (subreg:DI (reg:SI) 0)) then
700 resolve_simple_move will ask for the high part of the paradoxical
701 subreg, which does not have a value. Just return a zero. */
703 && paradoxical_subreg_p (op
))
704 return CONST0_RTX (outermode
);
706 gcc_assert (ret
!= NULL_RTX
);
710 /* Return whether we should resolve X into the registers into which it
714 resolve_reg_p (rtx x
)
716 return GET_CODE (x
) == CONCATN
;
719 /* Return whether X is a SUBREG of a register which we need to
723 resolve_subreg_p (rtx x
)
725 if (GET_CODE (x
) != SUBREG
)
727 return resolve_reg_p (SUBREG_REG (x
));
730 /* Look for SUBREGs in *LOC which need to be decomposed. */
733 resolve_subreg_use (rtx
*loc
, rtx insn
)
735 subrtx_ptr_iterator::array_type array
;
736 FOR_EACH_SUBRTX_PTR (iter
, array
, loc
, NONCONST
)
740 if (resolve_subreg_p (x
))
742 x
= simplify_subreg_concatn (GET_MODE (x
), SUBREG_REG (x
),
745 /* It is possible for a note to contain a reference which we can
746 decompose. In this case, return 1 to the caller to indicate
747 that the note must be removed. */
754 validate_change (insn
, loc
, x
, 1);
755 iter
.skip_subrtxes ();
757 else if (resolve_reg_p (x
))
758 /* Return 1 to the caller to indicate that we found a direct
759 reference to a register which is being decomposed. This can
760 happen inside notes, multiword shift or zero-extend
768 /* Resolve any decomposed registers which appear in register notes on
772 resolve_reg_notes (rtx_insn
*insn
)
776 note
= find_reg_equal_equiv_note (insn
);
779 int old_count
= num_validated_changes ();
780 if (resolve_subreg_use (&XEXP (note
, 0), NULL_RTX
))
781 remove_note (insn
, note
);
783 if (old_count
!= num_validated_changes ())
784 df_notes_rescan (insn
);
787 pnote
= ®_NOTES (insn
);
788 while (*pnote
!= NULL_RTX
)
793 switch (REG_NOTE_KIND (note
))
797 if (resolve_reg_p (XEXP (note
, 0)))
806 *pnote
= XEXP (note
, 1);
808 pnote
= &XEXP (note
, 1);
812 /* Return whether X can be decomposed into subwords. */
815 can_decompose_p (rtx x
)
819 unsigned int regno
= REGNO (x
);
821 if (HARD_REGISTER_NUM_P (regno
))
823 unsigned int byte
, num_bytes
, num_words
;
825 if (!interesting_mode_p (GET_MODE (x
), &num_bytes
, &num_words
))
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
;
849 unsigned int orig_size
, words
;
853 dest
= SET_DEST (set
);
854 orig_mode
= GET_MODE (dest
);
856 if (!interesting_mode_p (orig_mode
, &orig_size
, &words
))
858 gcc_assert (words
> 1);
862 /* We have to handle copying from a SUBREG of a decomposed reg where
863 the SUBREG is larger than word size. Rather than assume that we
864 can take a word_mode SUBREG of the destination, we copy to a new
865 register and then copy that to the destination. */
867 real_dest
= NULL_RTX
;
869 if (GET_CODE (src
) == SUBREG
870 && resolve_reg_p (SUBREG_REG (src
))
871 && (maybe_ne (SUBREG_BYTE (src
), 0)
872 || (GET_MODE_SIZE (orig_mode
)
873 != GET_MODE_SIZE (GET_MODE (SUBREG_REG (src
))))))
876 dest
= gen_reg_rtx (orig_mode
);
877 if (REG_P (real_dest
))
878 REG_ATTRS (dest
) = REG_ATTRS (real_dest
);
881 /* Similarly if we are copying to a SUBREG of a decomposed reg where
882 the SUBREG is larger than word size. */
884 if (GET_CODE (dest
) == SUBREG
885 && resolve_reg_p (SUBREG_REG (dest
))
886 && (maybe_ne (SUBREG_BYTE (dest
), 0)
887 || (GET_MODE_SIZE (orig_mode
)
888 != GET_MODE_SIZE (GET_MODE (SUBREG_REG (dest
))))))
893 reg
= gen_reg_rtx (orig_mode
);
894 minsn
= emit_move_insn (reg
, src
);
895 smove
= single_set (minsn
);
896 gcc_assert (smove
!= NULL_RTX
);
897 resolve_simple_move (smove
, minsn
);
901 /* If we didn't have any big SUBREGS of decomposed registers, and
902 neither side of the move is a register we are decomposing, then
903 we don't have to do anything here. */
905 if (src
== SET_SRC (set
)
906 && dest
== SET_DEST (set
)
907 && !resolve_reg_p (src
)
908 && !resolve_subreg_p (src
)
909 && !resolve_reg_p (dest
)
910 && !resolve_subreg_p (dest
))
916 /* It's possible for the code to use a subreg of a decomposed
917 register while forming an address. We need to handle that before
918 passing the address to emit_move_insn. We pass NULL_RTX as the
919 insn parameter to resolve_subreg_use because we can not validate
921 if (MEM_P (src
) || MEM_P (dest
))
926 resolve_subreg_use (&XEXP (src
, 0), NULL_RTX
);
928 resolve_subreg_use (&XEXP (dest
, 0), NULL_RTX
);
929 acg
= apply_change_group ();
933 /* If SRC is a register which we can't decompose, or has side
934 effects, we need to move via a temporary register. */
936 if (!can_decompose_p (src
)
937 || side_effects_p (src
)
938 || GET_CODE (src
) == ASM_OPERANDS
)
942 reg
= gen_reg_rtx (orig_mode
);
946 rtx_insn
*move
= emit_move_insn (reg
, src
);
949 rtx note
= find_reg_note (insn
, REG_INC
, NULL_RTX
);
951 add_reg_note (move
, REG_INC
, XEXP (note
, 0));
955 emit_move_insn (reg
, src
);
960 /* If DEST is a register which we can't decompose, or has side
961 effects, we need to first move to a temporary register. We
962 handle the common case of pushing an operand directly. We also
963 go through a temporary register if it holds a floating point
964 value. This gives us better code on systems which can't move
965 data easily between integer and floating point registers. */
967 dest_mode
= orig_mode
;
968 pushing
= push_operand (dest
, dest_mode
);
969 if (!can_decompose_p (dest
)
970 || (side_effects_p (dest
) && !pushing
)
971 || (!SCALAR_INT_MODE_P (dest_mode
)
972 && !resolve_reg_p (dest
)
973 && !resolve_subreg_p (dest
)))
975 if (real_dest
== NULL_RTX
)
977 if (!SCALAR_INT_MODE_P (dest_mode
))
978 dest_mode
= int_mode_for_mode (dest_mode
).require ();
979 dest
= gen_reg_rtx (dest_mode
);
980 if (REG_P (real_dest
))
981 REG_ATTRS (dest
) = REG_ATTRS (real_dest
);
986 unsigned int i
, j
, jinc
;
988 gcc_assert (orig_size
% UNITS_PER_WORD
== 0);
989 gcc_assert (GET_CODE (XEXP (dest
, 0)) != PRE_MODIFY
);
990 gcc_assert (GET_CODE (XEXP (dest
, 0)) != POST_MODIFY
);
992 if (WORDS_BIG_ENDIAN
== STACK_GROWS_DOWNWARD
)
1003 for (i
= 0; i
< words
; ++i
, j
+= jinc
)
1007 temp
= copy_rtx (XEXP (dest
, 0));
1008 temp
= adjust_automodify_address_nv (dest
, word_mode
, temp
,
1009 j
* UNITS_PER_WORD
);
1010 emit_move_insn (temp
,
1011 simplify_gen_subreg_concatn (word_mode
, src
,
1013 j
* UNITS_PER_WORD
));
1020 if (REG_P (dest
) && !HARD_REGISTER_NUM_P (REGNO (dest
)))
1021 emit_clobber (dest
);
1023 for (i
= 0; i
< words
; ++i
)
1024 emit_move_insn (simplify_gen_subreg_concatn (word_mode
, dest
,
1026 i
* UNITS_PER_WORD
),
1027 simplify_gen_subreg_concatn (word_mode
, src
,
1029 i
* UNITS_PER_WORD
));
1032 if (real_dest
!= NULL_RTX
)
1037 if (dest_mode
== orig_mode
)
1040 mdest
= simplify_gen_subreg (orig_mode
, dest
, GET_MODE (dest
), 0);
1041 minsn
= emit_move_insn (real_dest
, mdest
);
1043 if (AUTO_INC_DEC
&& MEM_P (real_dest
)
1044 && !(resolve_reg_p (real_dest
) || resolve_subreg_p (real_dest
)))
1046 rtx note
= find_reg_note (insn
, REG_INC
, NULL_RTX
);
1048 add_reg_note (minsn
, REG_INC
, XEXP (note
, 0));
1051 smove
= single_set (minsn
);
1052 gcc_assert (smove
!= NULL_RTX
);
1054 resolve_simple_move (smove
, minsn
);
1057 insns
= get_insns ();
1060 copy_reg_eh_region_note_forward (insn
, insns
, NULL_RTX
);
1062 emit_insn_before (insns
, insn
);
1064 /* If we get here via self-recursion, then INSN is not yet in the insns
1065 chain and delete_insn will fail. We only want to remove INSN from the
1066 current sequence. See PR56738. */
1067 if (in_sequence_p ())
1075 /* Change a CLOBBER of a decomposed register into a CLOBBER of the
1076 component registers. Return whether we changed something. */
1079 resolve_clobber (rtx pat
, rtx_insn
*insn
)
1082 machine_mode orig_mode
;
1083 unsigned int orig_size
, words
, i
;
1086 reg
= XEXP (pat
, 0);
1087 if (!resolve_reg_p (reg
) && !resolve_subreg_p (reg
))
1090 orig_mode
= GET_MODE (reg
);
1091 if (!interesting_mode_p (orig_mode
, &orig_size
, &words
))
1094 ret
= validate_change (NULL_RTX
, &XEXP (pat
, 0),
1095 simplify_gen_subreg_concatn (word_mode
, reg
,
1098 df_insn_rescan (insn
);
1099 gcc_assert (ret
!= 0);
1101 for (i
= words
- 1; i
> 0; --i
)
1105 x
= simplify_gen_subreg_concatn (word_mode
, reg
, orig_mode
,
1106 i
* UNITS_PER_WORD
);
1107 x
= gen_rtx_CLOBBER (VOIDmode
, x
);
1108 emit_insn_after (x
, insn
);
1111 resolve_reg_notes (insn
);
1116 /* A USE of a decomposed register is no longer meaningful. Return
1117 whether we changed something. */
1120 resolve_use (rtx pat
, rtx_insn
*insn
)
1122 if (resolve_reg_p (XEXP (pat
, 0)) || resolve_subreg_p (XEXP (pat
, 0)))
1128 resolve_reg_notes (insn
);
1133 /* A VAR_LOCATION can be simplified. */
1136 resolve_debug (rtx_insn
*insn
)
1138 subrtx_ptr_iterator::array_type array
;
1139 FOR_EACH_SUBRTX_PTR (iter
, array
, &PATTERN (insn
), NONCONST
)
1143 if (resolve_subreg_p (x
))
1145 x
= simplify_subreg_concatn (GET_MODE (x
), SUBREG_REG (x
),
1151 x
= copy_rtx (*loc
);
1153 if (resolve_reg_p (x
))
1154 *loc
= copy_rtx (x
);
1157 df_insn_rescan (insn
);
1159 resolve_reg_notes (insn
);
1162 /* Check if INSN is a decomposable multiword-shift or zero-extend and
1163 set the decomposable_context bitmap accordingly. SPEED_P is true
1164 if we are optimizing INSN for speed rather than size. Return true
1165 if INSN is decomposable. */
1168 find_decomposable_shift_zext (rtx_insn
*insn
, bool speed_p
)
1174 set
= single_set (insn
);
1179 if (GET_CODE (op
) != ASHIFT
1180 && GET_CODE (op
) != LSHIFTRT
1181 && GET_CODE (op
) != ASHIFTRT
1182 && GET_CODE (op
) != ZERO_EXTEND
)
1185 op_operand
= XEXP (op
, 0);
1186 if (!REG_P (SET_DEST (set
)) || !REG_P (op_operand
)
1187 || HARD_REGISTER_NUM_P (REGNO (SET_DEST (set
)))
1188 || HARD_REGISTER_NUM_P (REGNO (op_operand
))
1189 || GET_MODE (op
) != twice_word_mode
)
1192 if (GET_CODE (op
) == ZERO_EXTEND
)
1194 if (GET_MODE (op_operand
) != word_mode
1195 || !choices
[speed_p
].splitting_zext
)
1198 else /* left or right shift */
1200 bool *splitting
= (GET_CODE (op
) == ASHIFT
1201 ? choices
[speed_p
].splitting_ashift
1202 : GET_CODE (op
) == ASHIFTRT
1203 ? choices
[speed_p
].splitting_ashiftrt
1204 : choices
[speed_p
].splitting_lshiftrt
);
1205 if (!CONST_INT_P (XEXP (op
, 1))
1206 || !IN_RANGE (INTVAL (XEXP (op
, 1)), BITS_PER_WORD
,
1207 2 * BITS_PER_WORD
- 1)
1208 || !splitting
[INTVAL (XEXP (op
, 1)) - BITS_PER_WORD
])
1211 bitmap_set_bit (decomposable_context
, REGNO (op_operand
));
1214 bitmap_set_bit (decomposable_context
, REGNO (SET_DEST (set
)));
1219 /* Decompose a more than word wide shift (in INSN) of a multiword
1220 pseudo or a multiword zero-extend of a wordmode pseudo into a move
1221 and 'set to zero' insn. Return a pointer to the new insn when a
1222 replacement was done. */
1225 resolve_shift_zext (rtx_insn
*insn
)
1231 rtx src_reg
, dest_reg
, dest_upper
, upper_src
= NULL_RTX
;
1232 int src_reg_num
, dest_reg_num
, offset1
, offset2
, src_offset
;
1233 scalar_int_mode inner_mode
;
1235 set
= single_set (insn
);
1240 if (GET_CODE (op
) != ASHIFT
1241 && GET_CODE (op
) != LSHIFTRT
1242 && GET_CODE (op
) != ASHIFTRT
1243 && GET_CODE (op
) != ZERO_EXTEND
)
1246 op_operand
= XEXP (op
, 0);
1247 if (!is_a
<scalar_int_mode
> (GET_MODE (op_operand
), &inner_mode
))
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
&& GET_MODE_SIZE (inner_mode
) > UNITS_PER_WORD
)
1262 src_reg_num
= 1 - src_reg_num
;
1264 if (GET_CODE (op
) == ZERO_EXTEND
)
1265 dest_reg_num
= WORDS_BIG_ENDIAN
? 1 : 0;
1267 dest_reg_num
= 1 - src_reg_num
;
1269 offset1
= UNITS_PER_WORD
* dest_reg_num
;
1270 offset2
= UNITS_PER_WORD
* (1 - dest_reg_num
);
1271 src_offset
= UNITS_PER_WORD
* src_reg_num
;
1275 dest_reg
= simplify_gen_subreg_concatn (word_mode
, SET_DEST (set
),
1276 GET_MODE (SET_DEST (set
)),
1278 dest_upper
= simplify_gen_subreg_concatn (word_mode
, SET_DEST (set
),
1279 GET_MODE (SET_DEST (set
)),
1281 src_reg
= simplify_gen_subreg_concatn (word_mode
, op_operand
,
1282 GET_MODE (op_operand
),
1284 if (GET_CODE (op
) == ASHIFTRT
1285 && INTVAL (XEXP (op
, 1)) != 2 * BITS_PER_WORD
- 1)
1286 upper_src
= expand_shift (RSHIFT_EXPR
, word_mode
, copy_rtx (src_reg
),
1287 BITS_PER_WORD
- 1, NULL_RTX
, 0);
1289 if (GET_CODE (op
) != ZERO_EXTEND
)
1291 int shift_count
= INTVAL (XEXP (op
, 1));
1292 if (shift_count
> BITS_PER_WORD
)
1293 src_reg
= expand_shift (GET_CODE (op
) == ASHIFT
?
1294 LSHIFT_EXPR
: RSHIFT_EXPR
,
1296 shift_count
- BITS_PER_WORD
,
1297 dest_reg
, GET_CODE (op
) != ASHIFTRT
);
1300 if (dest_reg
!= src_reg
)
1301 emit_move_insn (dest_reg
, src_reg
);
1302 if (GET_CODE (op
) != ASHIFTRT
)
1303 emit_move_insn (dest_upper
, CONST0_RTX (word_mode
));
1304 else if (INTVAL (XEXP (op
, 1)) == 2 * BITS_PER_WORD
- 1)
1305 emit_move_insn (dest_upper
, copy_rtx (src_reg
));
1307 emit_move_insn (dest_upper
, upper_src
);
1308 insns
= get_insns ();
1312 emit_insn_before (insns
, insn
);
1317 fprintf (dump_file
, "; Replacing insn: %d with insns: ", INSN_UID (insn
));
1318 for (in
= insns
; in
!= insn
; in
= NEXT_INSN (in
))
1319 fprintf (dump_file
, "%d ", INSN_UID (in
));
1320 fprintf (dump_file
, "\n");
1327 /* Print to dump_file a description of what we're doing with shift code CODE.
1328 SPLITTING[X] is true if we are splitting shifts by X + BITS_PER_WORD. */
1331 dump_shift_choices (enum rtx_code code
, bool *splitting
)
1337 " Splitting mode %s for %s lowering with shift amounts = ",
1338 GET_MODE_NAME (twice_word_mode
), GET_RTX_NAME (code
));
1340 for (i
= 0; i
< BITS_PER_WORD
; i
++)
1343 fprintf (dump_file
, "%s%d", sep
, i
+ BITS_PER_WORD
);
1346 fprintf (dump_file
, "\n");
1349 /* Print to dump_file a description of what we're doing when optimizing
1350 for speed or size; SPEED_P says which. DESCRIPTION is a description
1351 of the SPEED_P choice. */
1354 dump_choices (bool speed_p
, const char *description
)
1356 unsigned int size
, factor
, i
;
1358 fprintf (dump_file
, "Choices when optimizing for %s:\n", description
);
1360 for (i
= 0; i
< MAX_MACHINE_MODE
; i
++)
1361 if (interesting_mode_p ((machine_mode
) i
, &size
, &factor
)
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
))
1519 sbitmap_iterator sbi
;
1520 bitmap_iterator iter
;
1523 propagate_pseudo_copies ();
1525 auto_sbitmap
sub_blocks (last_basic_block_for_fn (cfun
));
1526 bitmap_clear (sub_blocks
);
1528 EXECUTE_IF_SET_IN_BITMAP (decomposable_context
, 0, regno
, iter
)
1529 decompose_register (regno
);
1531 FOR_EACH_BB_FN (bb
, cfun
)
1535 FOR_BB_INSNS (bb
, insn
)
1542 pat
= PATTERN (insn
);
1543 if (GET_CODE (pat
) == CLOBBER
)
1544 resolve_clobber (pat
, insn
);
1545 else if (GET_CODE (pat
) == USE
)
1546 resolve_use (pat
, insn
);
1547 else if (DEBUG_INSN_P (insn
))
1548 resolve_debug (insn
);
1554 recog_memoized (insn
);
1555 extract_insn (insn
);
1557 set
= simple_move (insn
, speed_p
);
1560 rtx_insn
*orig_insn
= insn
;
1561 bool cfi
= control_flow_insn_p (insn
);
1563 /* We can end up splitting loads to multi-word pseudos
1564 into separate loads to machine word size pseudos.
1565 When this happens, we first had one load that can
1566 throw, and after resolve_simple_move we'll have a
1567 bunch of loads (at least two). All those loads may
1568 trap if we can have non-call exceptions, so they
1569 all will end the current basic block. We split the
1570 block after the outer loop over all insns, but we
1571 make sure here that we will be able to split the
1572 basic block and still produce the correct control
1573 flow graph for it. */
1575 || (cfun
->can_throw_non_call_exceptions
1576 && can_throw_internal (insn
)));
1578 insn
= resolve_simple_move (set
, insn
);
1579 if (insn
!= orig_insn
)
1581 recog_memoized (insn
);
1582 extract_insn (insn
);
1585 bitmap_set_bit (sub_blocks
, bb
->index
);
1590 rtx_insn
*decomposed_shift
;
1592 decomposed_shift
= resolve_shift_zext (insn
);
1593 if (decomposed_shift
!= NULL_RTX
)
1595 insn
= decomposed_shift
;
1596 recog_memoized (insn
);
1597 extract_insn (insn
);
1601 for (i
= recog_data
.n_operands
- 1; i
>= 0; --i
)
1602 resolve_subreg_use (recog_data
.operand_loc
[i
], insn
);
1604 resolve_reg_notes (insn
);
1606 if (num_validated_changes () > 0)
1608 for (i
= recog_data
.n_dups
- 1; i
>= 0; --i
)
1610 rtx
*pl
= recog_data
.dup_loc
[i
];
1611 int dup_num
= recog_data
.dup_num
[i
];
1612 rtx
*px
= recog_data
.operand_loc
[dup_num
];
1614 validate_unshare_change (insn
, pl
, *px
, 1);
1617 i
= apply_change_group ();
1624 /* If we had insns to split that caused control flow insns in the middle
1625 of a basic block, split those blocks now. Note that we only handle
1626 the case where splitting a load has caused multiple possibly trapping
1628 EXECUTE_IF_SET_IN_BITMAP (sub_blocks
, 0, i
, sbi
)
1630 rtx_insn
*insn
, *end
;
1633 bb
= BASIC_BLOCK_FOR_FN (cfun
, i
);
1634 insn
= BB_HEAD (bb
);
1639 if (control_flow_insn_p (insn
))
1641 /* Split the block after insn. There will be a fallthru
1642 edge, which is OK so we keep it. We have to create the
1643 exception edges ourselves. */
1644 fallthru
= split_block (bb
, insn
);
1645 rtl_make_eh_edge (NULL
, bb
, BB_END (bb
));
1646 bb
= fallthru
->dest
;
1647 insn
= BB_HEAD (bb
);
1650 insn
= NEXT_INSN (insn
);
1659 FOR_EACH_VEC_ELT (reg_copy_graph
, i
, b
)
1664 reg_copy_graph
.release ();
1666 BITMAP_FREE (decomposable_context
);
1667 BITMAP_FREE (non_decomposable_context
);
1668 BITMAP_FREE (subreg_context
);
1671 /* Implement first lower subreg pass. */
1675 const pass_data pass_data_lower_subreg
=
1677 RTL_PASS
, /* type */
1678 "subreg1", /* name */
1679 OPTGROUP_NONE
, /* optinfo_flags */
1680 TV_LOWER_SUBREG
, /* tv_id */
1681 0, /* properties_required */
1682 0, /* properties_provided */
1683 0, /* properties_destroyed */
1684 0, /* todo_flags_start */
1685 0, /* todo_flags_finish */
1688 class pass_lower_subreg
: public rtl_opt_pass
1691 pass_lower_subreg (gcc::context
*ctxt
)
1692 : rtl_opt_pass (pass_data_lower_subreg
, ctxt
)
1695 /* opt_pass methods: */
1696 virtual bool gate (function
*) { return flag_split_wide_types
!= 0; }
1697 virtual unsigned int execute (function
*)
1699 decompose_multiword_subregs (false);
1703 }; // class pass_lower_subreg
1708 make_pass_lower_subreg (gcc::context
*ctxt
)
1710 return new pass_lower_subreg (ctxt
);
1713 /* Implement second lower subreg pass. */
1717 const pass_data pass_data_lower_subreg2
=
1719 RTL_PASS
, /* type */
1720 "subreg2", /* name */
1721 OPTGROUP_NONE
, /* optinfo_flags */
1722 TV_LOWER_SUBREG
, /* tv_id */
1723 0, /* properties_required */
1724 0, /* properties_provided */
1725 0, /* properties_destroyed */
1726 0, /* todo_flags_start */
1727 TODO_df_finish
, /* todo_flags_finish */
1730 class pass_lower_subreg2
: public rtl_opt_pass
1733 pass_lower_subreg2 (gcc::context
*ctxt
)
1734 : rtl_opt_pass (pass_data_lower_subreg2
, ctxt
)
1737 /* opt_pass methods: */
1738 virtual bool gate (function
*) { return flag_split_wide_types
!= 0; }
1739 virtual unsigned int execute (function
*)
1741 decompose_multiword_subregs (true);
1745 }; // class pass_lower_subreg2
1750 make_pass_lower_subreg2 (gcc::context
*ctxt
)
1752 return new pass_lower_subreg2 (ctxt
);