summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/cc/cc_int/unroll.c
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/usr.bin/cc/cc_int/unroll.c')
-rw-r--r--gnu/usr.bin/cc/cc_int/unroll.c162
1 files changed, 81 insertions, 81 deletions
diff --git a/gnu/usr.bin/cc/cc_int/unroll.c b/gnu/usr.bin/cc/cc_int/unroll.c
index c82266e..b498843 100644
--- a/gnu/usr.bin/cc/cc_int/unroll.c
+++ b/gnu/usr.bin/cc/cc_int/unroll.c
@@ -140,7 +140,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
struct _factor { int factor, count; } factors[NUM_FACTORS]
= { {2, 0}, {3, 0}, {5, 0}, {7, 0}};
-
+
/* Describes the different types of loop unrolling performed. */
enum unroll_types { UNROLL_COMPLETELY, UNROLL_MODULO, UNROLL_NAIVE };
@@ -792,7 +792,7 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
/* Calculate the difference between the final and initial values.
Final value may be a (plus (reg x) (const_int 1)) rtx.
Let the following cse pass simplify this if initial value is
- a constant.
+ a constant.
We must copy the final and initial values here to avoid
improperly shared rtl. */
@@ -861,7 +861,7 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
For the negative increment case, the branch here could easily
be merged with the `0' case branch above. For the positive
increment case, it is not clear how this can be simplified. */
-
+
if (abs_inc != 1)
{
int cmp_const;
@@ -885,7 +885,7 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
sequence = gen_sequence ();
end_sequence ();
emit_insn_before (sequence, loop_start);
-
+
/* Only the last copy of the loop body here needs the exit
test, so set copy_end to exclude the compare/branch here,
and then reset it inside the loop when get to the last
@@ -1066,7 +1066,7 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
{
insn = PREV_INSN (copy_start);
pattern = PATTERN (insn);
-
+
tem = map->label_map[CODE_LABEL_NUMBER
(XEXP (SET_SRC (pattern), 0))];
SET_SRC (pattern) = gen_rtx (LABEL_REF, VOIDmode, tem);
@@ -1096,7 +1096,7 @@ unroll_loop (loop_end, insn_count, loop_start, end_insert_before,
else
safety_label = emit_label_after (gen_label_rtx (), copy_end);
- /* Delete all of the original loop instructions. Don't delete the
+ /* Delete all of the original loop instructions. Don't delete the
LOOP_BEG note, or the first code label in the loop. */
insn = NEXT_INSN (copy_start);
@@ -1315,7 +1315,7 @@ calculate_giv_inc (pattern, src_insn, regno)
pattern = PATTERN (src_insn);
if (GET_CODE (SET_SRC (pattern)) != PLUS)
abort ();
-
+
/* The last insn emitted is not needed, so delete it to avoid confusing
the second cse pass. This insn sets the giv unnecessarily. */
delete_insn (get_last_insn ());
@@ -1354,7 +1354,7 @@ calculate_giv_inc (pattern, src_insn, regno)
if (GET_CODE (increment) != CONST_INT)
abort ();
-
+
/* The insn loading the constant into a register is no longer needed,
so delete it. */
delete_insn (get_last_insn ());
@@ -1438,7 +1438,7 @@ final_reg_note_copy (notes, map)
/* Copy each instruction in the loop, substituting from map as appropriate.
This is very similar to a loop in expand_inline_function. */
-
+
static void
copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
unroll_type, start_label, loop_end, insert_before,
@@ -1472,29 +1472,29 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
map->label_map[CODE_LABEL_NUMBER (start_label)] = start_label;
start_sequence ();
-
+
insn = copy_start;
do
{
insn = NEXT_INSN (insn);
-
+
map->orig_asm_operands_vector = 0;
-
+
switch (GET_CODE (insn))
{
case INSN:
pattern = PATTERN (insn);
copy = 0;
giv_inc = 0;
-
+
/* Check to see if this is a giv that has been combined with
- some split address givs. (Combined in the sense that
+ some split address givs. (Combined in the sense that
`combine_givs' in loop.c has put two givs in the same register.)
In this case, we must search all givs based on the same biv to
find the address givs. Then split the address givs.
Do this before splitting the giv, since that may map the
SET_DEST to a new register. */
-
+
if (GET_CODE (pattern) == SET
&& GET_CODE (SET_DEST (pattern)) == REG
&& addr_combined_regs[REGNO (SET_DEST (pattern))])
@@ -1502,10 +1502,10 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
struct iv_class *bl;
struct induction *v, *tv;
int regno = REGNO (SET_DEST (pattern));
-
+
v = addr_combined_regs[REGNO (SET_DEST (pattern))];
bl = reg_biv_class[REGNO (v->src_reg)];
-
+
/* Although the giv_inc amount is not needed here, we must call
calculate_giv_inc here since it might try to delete the
last insn emitted. If we wait until later to call it,
@@ -1526,24 +1526,24 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
if (tv->mult_val != v->mult_val)
this_giv_inc = (this_giv_inc / INTVAL (v->mult_val)
* INTVAL (tv->mult_val));
-
+
tv->dest_reg = plus_constant (tv->dest_reg, this_giv_inc);
*tv->location = tv->dest_reg;
-
+
if (last_iteration && unroll_type != UNROLL_COMPLETELY)
{
/* Must emit an insn to increment the split address
giv. Add in the const_adjust field in case there
was a constant eliminated from the address. */
rtx value, dest_reg;
-
+
/* tv->dest_reg will be either a bare register,
or else a register plus a constant. */
if (GET_CODE (tv->dest_reg) == REG)
dest_reg = tv->dest_reg;
else
dest_reg = XEXP (tv->dest_reg, 0);
-
+
/* Check for shared address givs, and avoid
incrementing the shared psuedo reg more than
once. */
@@ -1563,7 +1563,7 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
emit_unrolled_add (dest_reg, XEXP (value, 0),
XEXP (value, 1));
}
-
+
/* Reset the giv to be just the register again, in case
it is used after the set we have just emitted.
We must subtract the const_adjust factor added in
@@ -1574,22 +1574,22 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
}
}
}
-
+
/* If this is a setting of a splittable variable, then determine
how to split the variable, create a new set based on this split,
and set up the reg_map so that later uses of the variable will
use the new split variable. */
-
+
dest_reg_was_split = 0;
-
+
if (GET_CODE (pattern) == SET
&& GET_CODE (SET_DEST (pattern)) == REG
&& splittable_regs[REGNO (SET_DEST (pattern))])
{
int regno = REGNO (SET_DEST (pattern));
-
+
dest_reg_was_split = 1;
-
+
/* Compute the increment value for the giv, if it wasn't
already computed above. */
@@ -1602,7 +1602,7 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
{
/* Completely unrolling the loop. Set the induction
variable to a known constant value. */
-
+
/* The value in splittable_regs may be an invariant
value, so we must use plus_constant here. */
splittable_regs[regno]
@@ -1629,7 +1629,7 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
be a constant plus the original register. Except
on the last iteration, when the result has to
go back into the original iteration var register. */
-
+
/* Handle bivs which must be mapped to a new register
when split. This happens for bivs which need their
final value set before loop entry. The new register
@@ -1642,18 +1642,18 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
giv_src_reg = reg_biv_class[regno]->biv->src_reg;
giv_dest_reg = giv_src_reg;
}
-
+
#if 0
/* If non-reduced/final-value givs were split, then
this would have to remap those givs also. See
find_splittable_regs. */
#endif
-
+
splittable_regs[regno]
= GEN_INT (INTVAL (giv_inc)
+ INTVAL (splittable_regs[regno]));
giv_inc = splittable_regs[regno];
-
+
/* Now split the induction variable by changing the dest
of this insn to a new register, and setting its
reg_map entry to point to this new register.
@@ -1691,7 +1691,7 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
copy = emit_insn (pattern);
}
REG_NOTES (copy) = initial_reg_note_copy (REG_NOTES (insn), map);
-
+
#ifdef HAVE_cc0
/* If this insn is setting CC0, it may need to look at
the insn that uses CC0 to see what type of insn it is.
@@ -1731,7 +1731,7 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
map->const_age_map[regno] = -1;
}
break;
-
+
case JUMP_INSN:
pattern = copy_rtx_and_substitute (PATTERN (insn), map);
copy = emit_jump_insn (pattern);
@@ -1773,7 +1773,7 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
abort ();
}
}
-
+
#ifdef HAVE_cc0
if (cc0_insn)
try_constants (cc0_insn, map);
@@ -1813,7 +1813,7 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
JUMP_LABEL (copy) = map->label_map[CODE_LABEL_NUMBER
(JUMP_LABEL (insn))];
}
-
+
/* If this is a non-local jump, then must increase the label
use count so that the label will not be deleted when the
original jump is deleted. */
@@ -1860,7 +1860,7 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
emit_barrier ();
}
break;
-
+
case CALL_INSN:
pattern = copy_rtx_and_substitute (PATTERN (insn), map);
copy = emit_call_insn (pattern);
@@ -1882,7 +1882,7 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
map->const_equiv_map[i] = 0;
break;
-
+
case CODE_LABEL:
/* If this is the loop start label, then we don't need to emit a
copy of this label since no one will use it. */
@@ -1893,15 +1893,15 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
map->const_age++;
}
break;
-
+
case BARRIER:
copy = emit_barrier ();
break;
-
+
case NOTE:
/* VTOP notes are valid only before the loop exit test. If placed
anywhere else, loop may generate bad code. */
-
+
if (NOTE_LINE_NUMBER (insn) != NOTE_INSN_DELETED
&& (NOTE_LINE_NUMBER (insn) != NOTE_INSN_LOOP_VTOP
|| (last_iteration && unroll_type != UNROLL_COMPLETELY)))
@@ -1910,16 +1910,16 @@ copy_loop_body (copy_start, copy_end, map, exit_label, last_iteration,
else
copy = 0;
break;
-
+
default:
abort ();
break;
}
-
+
map->insn_map[INSN_UID (insn)] = copy;
}
while (insn != copy_end);
-
+
/* Now finish coping the REG_NOTES. */
insn = copy_start;
do
@@ -2011,7 +2011,7 @@ back_branch_in_range_p (insn, loop_start, loop_end)
if (GET_CODE (p) == JUMP_INSN)
{
target_insn = JUMP_LABEL (p);
-
+
/* Search from loop_start to insn, to see if one of them is
the target_insn. We can't use INSN_LUID comparisons here,
since insn may not have an LUID entry. */
@@ -2077,7 +2077,7 @@ fold_rtx_mult_add (mult1, mult2, add1, mode)
Returns the increment value as an rtx, simplified as much as possible,
if it can be calculated. Otherwise, returns 0. */
-rtx
+rtx
biv_total_increment (bl, loop_start, loop_end)
struct iv_class *bl;
rtx loop_start, loop_end;
@@ -2184,7 +2184,7 @@ iteration_info (iteration_var, initial_value, increment, loop_start, loop_end)
bl = reg_biv_class[REGNO (v->src_reg)];
*initial_value = fold_rtx_mult_add (v->mult_val, bl->initial_value,
v->add_val, v->mode);
-
+
/* Increment value is mult_val times the increment value of the biv. */
*increment = biv_total_increment (bl, loop_start, loop_end);
@@ -2359,7 +2359,7 @@ find_splittable_regs (unroll_type, loop_start, loop_end, end_insert_before,
|| REGNO (bl->initial_value) < FIRST_PSEUDO_REGISTER))
{
rtx tem = gen_reg_rtx (bl->biv->mode);
-
+
emit_insn_before (gen_move_insn (tem, bl->biv->src_reg),
loop_start);
@@ -2473,7 +2473,7 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
&& (! v->always_computable
|| back_branch_in_range_p (v->insn, loop_start, loop_end)))
continue;
-
+
/* The giv increment value must be a constant. */
giv_inc = fold_rtx_mult_add (v->mult_val, increment, const0_rtx,
v->mode);
@@ -2485,7 +2485,7 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
the loop, or else the final value of the giv must be known.
Otherwise, it is not safe to split the giv since it may not have the
proper value on loop exit. */
-
+
/* The used outside loop test will fail for DEST_ADDR givs. They are
never used outside the loop anyways, so it is always safe to split a
DEST_ADDR giv. */
@@ -2525,11 +2525,11 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
emit_insn_before (gen_move_insn (tem, v->dest_reg), loop_start);
emit_insn_before (gen_move_insn (v->dest_reg, final_value),
loop_start);
-
+
if (loop_dump_stream)
fprintf (loop_dump_stream, "Giv %d mapped to %d for split.\n",
REGNO (v->dest_reg), REGNO (tem));
-
+
v->src_reg = tem;
}
#endif
@@ -2601,7 +2601,7 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
v->add_val, tem, loop_start);
value = tem;
}
-
+
splittable_regs[REGNO (v->new_reg)] = value;
}
else
@@ -2621,7 +2621,7 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
catch some of the common cases of this. Currently, I leave
the work of simplifying multiple address givs to the
following cse pass. */
-
+
/* As a special case, if we have multiple identical address givs
within a single instruction, then we do use a single psuedo
reg for both. This is necessary in case one is a match_dup
@@ -2648,13 +2648,13 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
/* If the address giv has a constant in its new_reg value,
then this constant can be pulled out and put in value,
instead of being part of the initialization code. */
-
+
if (GET_CODE (v->new_reg) == PLUS
&& GET_CODE (XEXP (v->new_reg, 1)) == CONST_INT)
{
v->dest_reg
= plus_constant (tem, INTVAL (XEXP (v->new_reg,1)));
-
+
/* Only succeed if this will give valid addresses.
Try to validate both the first and the last
address resulting from loop unrolling, if
@@ -2681,7 +2681,7 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
}
else
v->dest_reg = tem;
-
+
/* If the address hasn't been checked for validity yet, do so
now, and fail completely if either the first or the last
unrolled copy of the address is not a valid address. */
@@ -2698,7 +2698,7 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
INSN_UID (v->insn));
continue;
}
-
+
/* To initialize the new register, just move the value of
new_reg into it. This is not guaranteed to give a valid
instruction on machines with complex addressing modes.
@@ -2733,7 +2733,7 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
else
{
v->dest_reg = value;
-
+
/* Check the resulting address for validity, and fail
if the resulting address would be illegal. */
if (! memory_address_p (v->mem_mode, v->dest_reg)
@@ -2749,28 +2749,28 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
continue;
}
}
-
+
/* Store the value of dest_reg into the insn. This sharing
will not be a problem as this insn will always be copied
later. */
-
+
*v->location = v->dest_reg;
-
+
/* If this address giv is combined with a dest reg giv, then
save the base giv's induction pointer so that we will be
able to handle this address giv properly. The base giv
itself does not have to be splittable. */
-
+
if (v->same && v->same->giv_type == DEST_REG)
addr_combined_regs[REGNO (v->same->new_reg)] = v->same;
-
+
if (GET_CODE (v->new_reg) == REG)
{
/* This giv maybe hasn't been combined with any others.
Make sure that it's giv is marked as splittable here. */
-
+
splittable_regs[REGNO (v->new_reg)] = value;
-
+
/* Make it appear to depend upon itself, so that the
giv will be properly split in the main loop above. */
if (! v->same)
@@ -2793,7 +2793,7 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
it makes sense to reduce&split givs when possible, as this will
result in simpler instructions, and will not require that a reg
be live across loop iterations. */
-
+
splittable_regs[REGNO (v->dest_reg)] = value;
fprintf (stderr, "Giv %d at insn %d not reduced\n",
REGNO (v->dest_reg), INSN_UID (v->insn));
@@ -2801,7 +2801,7 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
continue;
#endif
}
-
+
/* Givs are only updated once by definition. Mark it so if this is
a splittable register. Don't need to do anything for address givs
where this may not be a register. */
@@ -2810,11 +2810,11 @@ find_splittable_givs (bl, unroll_type, loop_start, loop_end, increment,
splittable_regs_updates[REGNO (v->new_reg)] = 1;
result++;
-
+
if (loop_dump_stream)
{
int regnum;
-
+
if (GET_CODE (v->dest_reg) == CONST_INT)
regnum = -1;
else if (GET_CODE (v->dest_reg) != REG)
@@ -2896,7 +2896,7 @@ reg_dead_after_loop (reg, loop_start, loop_end)
/* Try to calculate the final value of the biv, the value it will have at
the end of the loop. If we can do it, return that value. */
-
+
rtx
final_biv_value (bl, loop_start, loop_end)
struct iv_class *bl;
@@ -2918,7 +2918,7 @@ final_biv_value (bl, loop_start, loop_end)
if (loop_dump_stream)
fprintf (loop_dump_stream,
"Final biv value for %d, reversed biv.\n", bl->regno);
-
+
return const0_rtx;
}
@@ -2933,7 +2933,7 @@ final_biv_value (bl, loop_start, loop_end)
&& invariant_p (bl->initial_value))
{
increment = biv_total_increment (bl, loop_start, loop_end);
-
+
if (increment && invariant_p (increment))
{
/* Can calculate the loop exit value, emit insns after loop
@@ -2950,7 +2950,7 @@ final_biv_value (bl, loop_start, loop_end)
if (loop_dump_stream)
fprintf (loop_dump_stream,
"Final biv value for %d, calculated.\n", bl->regno);
-
+
return tem;
}
}
@@ -3000,7 +3000,7 @@ final_giv_value (v, loop_start, loop_end)
/* Try to calculate the final value as a function of the biv it depends
upon. The only exit from the loop must be the fall through at the bottom
(otherwise it may not have its final value when the loop exits). */
-
+
/* ??? Can calculate the final giv value by subtracting off the
extra biv increments times the giv's mult_val. The loop must have
only one exit for this to work, but the loop iterations does not need
@@ -3022,7 +3022,7 @@ final_giv_value (v, loop_start, loop_end)
{
/* Can calculate the loop exit value of its biv as
(loop_n_iterations * increment) + initial_value */
-
+
/* The loop exit value of the giv is then
(final_biv_value - extra increments) * mult_val + add_val.
The extra increments are any increments to the biv which
@@ -3055,11 +3055,11 @@ final_giv_value (v, loop_start, loop_end)
emit_insn_before (seq, insert_before);
}
}
-
+
/* Now calculate the giv's final value. */
emit_iv_add_mult (tem, v->mult_val, v->add_val, tem,
insert_before);
-
+
if (loop_dump_stream)
fprintf (loop_dump_stream,
"Final giv value for %d, calc from biv's value.\n",
@@ -3107,7 +3107,7 @@ loop_iterations (loop_start, loop_end)
/* First find the iteration variable. If the last insn is a conditional
branch, and the insn before tests a register value, make that the
iteration variable. */
-
+
loop_initial_value = 0;
loop_increment = 0;
loop_final_value = 0;
@@ -3161,7 +3161,7 @@ loop_iterations (loop_start, loop_end)
if (GET_CODE (comparison_value) == REG && invariant_p (comparison_value))
{
rtx insn, set;
-
+
for (insn = PREV_INSN (loop_start); insn ; insn = PREV_INSN (insn))
{
if (GET_CODE (insn) == CODE_LABEL)
@@ -3272,7 +3272,7 @@ loop_iterations (loop_start, loop_end)
will overflow before the loop exits), 4 infinite loop cases, and 15
immediate exit (0 or 1 iteration depending on loop type) cases.
Only try to optimize the normal cases. */
-
+
/* (compare_dir/final_larger/increment_dir)
Normal cases: (0/-1/-1), (0/1/1), (-1/-1/-1), (1/1/1)
Reverse cases: (0/-1/1), (0/1/-1), (-1/-1/1), (1/1/-1)
OpenPOWER on IntegriCloud