aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelvin Nilsen <kelvin@gcc.gnu.org>2015-11-20 04:12:54 +0000
committerKelvin Nilsen <kelvin@gcc.gnu.org>2015-11-20 04:12:54 +0000
commit992a32ffde08213fd5968186ce70f9e00467fa2c (patch)
tree39a3a9827ded835f69ad4141f517165b0788e365
parentdf88659ddac9ff8321ee18ada46448726818a3fd (diff)
finishing touches
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/ibm/kelvin-1@230639 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/cfgloopmanip.c238
-rw-r--r--gcc/cfgloopmanip.h3
-rw-r--r--gcc/loop-iv.c47
-rw-r--r--gcc/loop-unroll.c129
4 files changed, 28 insertions, 389 deletions
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c
index cf57853a31b..c79ed7c3c63 100644
--- a/gcc/cfgloopmanip.c
+++ b/gcc/cfgloopmanip.c
@@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
-#define KELVIN_PATCH
#include "config.h"
#include "system.h"
#include "coretypes.h"
@@ -34,7 +33,6 @@ along with GCC; see the file COPYING3. If not see
#include "gimplify-me.h"
#include "tree-ssa-loop-manip.h"
#include "dumpfile.h"
-#ifdef KELVIN_PATCH
#include "diagnostic-core.h"
/* Use a command-line option to set the flag_checking option to enforce
@@ -43,11 +41,6 @@ along with GCC; see the file COPYING3. If not see
sum of incoming edge frequencies for the loop header block.
b. The sum of predecessor edge frequencies for every block
in the loop equals the frequency of that block. */
-#define KELVIN_NOISE
-#ifdef KELVIN_NOISE
-#include "kelvin-debugs.c"
-#endif
-#endif
static void copy_loops_to (struct loop **, int,
struct loop *);
@@ -59,22 +52,13 @@ static void fix_loop_placements (struct loop *, bool *);
static bool fix_bb_placement (basic_block);
static void fix_bb_placements (basic_block, bool *, bitmap);
-#ifdef KELVIN_PATCH
/* Return true iff BLOCK is considered to reside within the loop
represented by LOOP_PTR. */
bool
in_loop_p (basic_block block, struct loop *loop_ptr)
{
- basic_block *bbs = get_loop_body (loop_ptr);
- bool result = false;
-
- for (unsigned int i = 0; i < loop_ptr->num_nodes; i++)
- {
- if (bbs[i] == block)
- result = true;
- }
- free (bbs);
- return result;
+ return (block->loop_father == loop_ptr)
+ || flow_loop_nested_p (loop_ptr, block->loop_father);
}
/* Zero all frequencies associated with loop LOOP_PTR. */
@@ -135,7 +119,11 @@ in_call_chain_p (edge an_edge, ladder_rung_p ladder_rung)
terminates if INCOMING_EDGE is known to exit this loop, or
if the destination of INCOMING_EDGE has already been visited
in this recursive traversal, or if the destination of INCOMING_EDGE
- is the loop header. */
+ is the loop header.
+
+ Note that depth of recursion is limited to the maximum number of
+ blocks visited on a non-iterative traversal of the blocks contained
+ within the loop. */
static void
recursively_zero_frequency (struct loop *loop_ptr, vec<edge> exit_edges,
ladder_rung_p ladder_rung,
@@ -180,57 +168,6 @@ recursion_detected_p (basic_block candidate, ladder_rung_p lower_steps)
return false;
}
-/* Return true iff CANDIDATE is contained within the loop represented
- by LOOP_HEADER and LOOP_LATCH.
-
- We consider the block to be within the loop if there exists a path
- within the control flow graph from this node to the loop's latch
- which does not pass through the loop's header. (If all paths to
- the latch pass through the loop header, then the node is contained
- within an outer-nested loop but not within this loop.)
-
- Note that if a CANDIDATE's successor is in the loop and the successor
- is not the loop header, then the candidate itself is also in the loop.
- If none of the successors of a candidate are in the loop, then the
- candidate itself is not in the loop. */
-static bool
-in_loop_of_header_p (basic_block candidate, basic_block loop_header,
- basic_block loop_latch, bool start_of_recursion,
- ladder_rung_p lower_steps)
-{
- if (candidate == loop_latch)
- return true;
- else if (candidate == loop_header)
- return start_of_recursion;
- else if (!start_of_recursion
- && recursion_detected_p (candidate, lower_steps))
- {
- /* if recursion revisits a node already visited and the loop latch
- was not visited in the call chain, then we are traversing an
- iterative path that belongs to an outer-nested loop. */
- return false;
- }
- else
- {
- struct block_ladder_rung new_step;
-
- new_step.block = candidate;
- new_step.lower_rung = lower_steps;
-
- edge_iterator ei;
- edge successor_edge;
- FOR_EACH_EDGE (successor_edge, ei, candidate->succs)
- {
- basic_block successor = successor_edge->dest;
- if (in_loop_of_header_p (successor, loop_header,
- loop_latch, false, &new_step))
- return true;
- }
- /* None of the successors was in loop */
- return false;
- }
-}
-
/* Add CANDIDATE into the RESULTS vector if CANDIDATE
is in the loop identified by the LOOP_HEADER and LOOP_LATCH
arguments and it is not already contained within the RESULTS
@@ -245,10 +182,14 @@ in_loop_of_header_p (basic_block candidate, basic_block loop_header,
If and only if CANDIDATE is added to the RESULTS vector, recursively
do the same for each successor of the CANDIDATE block.
- Return the potentially modified RESULTS vector. */
+ Return the potentially modified RESULTS vector.
+
+ Note that depth of recursion is limited to the maximum number of
+ blocks visited on a non-iterative traversal of the blocks contained
+ within the loop. */
static vec<basic_block>
recursively_get_loop_blocks (basic_block candidate, vec<basic_block> results,
- basic_block loop_header, basic_block loop_latch)
+ struct loop* loop_ptr)
{
basic_block bb;
unsigned int u;
@@ -260,10 +201,10 @@ recursively_get_loop_blocks (basic_block candidate, vec<basic_block> results,
return results;
}
- if (in_loop_of_header_p (candidate, loop_header, loop_latch, true, NULL))
+ if (in_loop_p (candidate, loop_ptr))
{
results.safe_push (candidate);
-
+
edge_iterator ei;
edge successor;
FOR_EACH_EDGE (successor, ei, candidate->succs)
@@ -271,7 +212,7 @@ recursively_get_loop_blocks (basic_block candidate, vec<basic_block> results,
if (successor->probability != 0)
{
results = recursively_get_loop_blocks (successor->dest, results,
- loop_header, loop_latch);
+ loop_ptr);
}
}
}
@@ -286,19 +227,10 @@ get_loop_blocks (struct loop *loop_ptr)
vec<basic_block> results;
results = vNULL;
- results = recursively_get_loop_blocks (loop_ptr->header, results,
- loop_ptr->header, loop_ptr->latch);
+ results = recursively_get_loop_blocks (loop_ptr->header, results, loop_ptr);
return results;
}
-/* Return true iff BB is contained within the loop represented by LOOP_PTR */
-static bool
-in_block_set_p (basic_block bb, struct loop* loop_ptr)
-{
- return (bb->loop_father == loop_ptr)
- || flow_loop_nested_p (loop_ptr, bb->loop_father);
-}
-
/* Zero all frequencies for all blocks contained within the loop
represented by LOOP_PTR which are reachable from BLOCK without
passing through the loop header. If BLOCK is not within the loop,
@@ -316,7 +248,7 @@ in_block_set_p (basic_block bb, struct loop* loop_ptr)
static void
zero_partial_loop_frequencies (struct loop *loop_ptr, basic_block block)
{
- if (in_block_set_p (block, loop_ptr))
+ if (in_loop_p (block, loop_ptr))
{
struct block_ladder_rung ladder_rung;
ladder_rung.block = block;
@@ -347,7 +279,11 @@ zero_partial_loop_frequencies (struct loop *loop_ptr, basic_block block)
terminates if INCOMING_EDGE is known to exit this loop, or
if the destination of INCOMING_EDGE has already been visited
in this recursive traversal, or if the destination of INCOMING_EDGE
- is the loop header. */
+ is the loop header.
+
+ Note that depth of recursion is limited to the maximum number of
+ blocks visited on a non-iterative traversal of the blocks contained
+ within the loop. */
static void
recursively_increment_frequency (struct loop *loop_ptr, vec<edge> exit_edges,
ladder_rung_p ladder_rung, edge incoming_edge,
@@ -395,7 +331,7 @@ void
increment_loop_frequencies (struct loop *loop_ptr, basic_block block,
int frequency_increment)
{
- if (in_block_set_p (block, loop_ptr))
+ if (in_loop_p (block, loop_ptr))
{
struct block_ladder_rung ladder_rung;
ladder_rung.block = block;
@@ -467,7 +403,7 @@ check_loop_frequency_integrity (struct loop *loop_ptr)
edge_iterator ei;
edge a_predecessor;
FOR_EACH_EDGE (a_predecessor, ei, header->preds)
- if (!in_block_set_p (a_predecessor->src, loop_ptr))
+ if (!in_loop_p (a_predecessor->src, loop_ptr))
incoming_frequency += EDGE_FREQUENCY (a_predecessor);
int outgoing_frequency = 0;
@@ -490,7 +426,6 @@ check_loop_frequency_integrity (struct loop *loop_ptr)
loop_body.release ();
exit_edges.release ();
}
-#endif
/* Checks whether basic block BB is dominated by DATA. */
static bool
@@ -1546,17 +1481,11 @@ can_duplicate_loop_p (const struct loop *loop)
}
static void
-#ifdef KELVIN_PATCH
/* Sets probability and count of edge E to zero. The probability and count
is redistributed evenly to the remaining edges coming from E->src
and is propagated transitively to all nodes contained within the
loop identified by LOOP_PTR and reachable from E->src. */
set_zero_probability (struct loop* loop_ptr, edge e)
-#else
-/* Sets probability and count of edge E to zero. The probability and count
- is redistributed evenly to the remaining edges coming from E->src. */
-set_zero_probability (edge e)
-#endif
{
basic_block bb = e->src;
edge_iterator ei;
@@ -1564,12 +1493,10 @@ set_zero_probability (edge e)
unsigned n = EDGE_COUNT (bb->succs);
gcov_type cnt = e->count, cnt1;
unsigned prob = e->probability, prob1;
-#ifdef KELVIN_PATCH
int original_edge_frequency;
int new_edge_frequency;
int change_in_edge_frequency;
bool edge_originates_in_loop = in_loop_p (bb, loop_ptr);
-#endif
gcc_assert (n > 1);
cnt1 = cnt / (n - 1);
@@ -1580,7 +1507,6 @@ set_zero_probability (edge e)
if (ae == e)
continue;
-#ifdef KELVIN_PATCH
if (edge_originates_in_loop)
{
original_edge_frequency = EDGE_FREQUENCY (ae);
@@ -1597,15 +1523,10 @@ set_zero_probability (edge e)
ae->probability += prob1;
ae->count += cnt1;
}
-#else
- ae->probability += prob1;
- ae->count += cnt1;
-#endif
last = ae;
}
/* Move the rest to one of the edges. */
-#ifdef KELVIN_PATCH
if (edge_originates_in_loop)
{
original_edge_frequency = EDGE_FREQUENCY (last);
@@ -1622,11 +1543,6 @@ set_zero_probability (edge e)
last->probability += prob % (n - 1);
last->count += cnt % (n - 1);
}
-#else
- last->probability += prob % (n - 1);
- last->count += cnt % (n - 1);
-#endif
-#ifdef KELVIN_PATCH
if (edge_originates_in_loop)
{
original_edge_frequency = EDGE_FREQUENCY (e);
@@ -1643,10 +1559,6 @@ set_zero_probability (edge e)
e->probability = 0;
e->count = 0;
}
-#else
- e->probability = 0;
- e->count = 0;
-#endif
}
/* Duplicates body of LOOP to given edge E NDUPL times. Takes care of updating
@@ -1687,7 +1599,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
bitmap bbs_to_scale = NULL;
bitmap_iterator bi;
-#ifdef KELVIN_PATCH
/* Remember the initial ratio between frequency of edge into loop
header and the frequency of the loop header. Preserve this ratio
when we make adjustments within the loop. This distinction is
@@ -1713,30 +1624,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
if (!in_loop_p (predecessor->src, loop))
preheader_frequency += EDGE_FREQUENCY (predecessor);
int exit_ratio = (header_frequency * 10000 - 5000) / preheader_frequency;
-#ifdef KELVIN_NOISE
- {
- fprintf(stderr,
- "duplicate_loop_to_header_edge(ndupl: %d)\n", ndupl);
- kdn_dump_copy_flags(stderr, " flags: ", flags);
- kdn_dump_sbitmap(stderr, " wont_exit: ", wont_exit);
- fprintf(stderr, " header edge: ");
- kdn_dump_edge(stderr, e);
- fprintf(stderr, " original edge: ");
- kdn_dump_edge(stderr, orig);
- fprintf(stderr, " to_remove edges:\n");
- unsigned int i;
- edge edge_to_remove;
- FOR_EACH_VEC_ELT (*to_remove, i, edge_to_remove)
- kdn_dump_edge(stderr, edge_to_remove);
- fprintf(stderr,
- " preheader frequency: %d, header frequency: %d, exit_ratio: %d\n",
- preheader_frequency, header_frequency, exit_ratio);
- fprintf(stderr, "The loop context:");
- kdn_dump_loop(stderr, loop);
- kdn_dump_all_blocks(stderr, loop);
- }
-#endif
-#endif
gcc_assert (e->dest == loop->header);
gcc_assert (ndupl > 0);
@@ -1824,10 +1711,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
should've managed the flags so all except for original loop
has won't exist set. */
scale_act = GCOV_COMPUTE_SCALE (wanted_freq, freq_in);
-#ifdef KELVIN_NOISE
- fprintf(stderr, "scale_act computed from GCOV_COMPUTE_SCALE: %d\n",
- scale_act);
-#endif
/* Now simulate the duplication adjustments and compute header
frequency of the last copy. */
for (i = 0; i < ndupl; i++)
@@ -1848,11 +1731,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
}
scale_main = GCOV_COMPUTE_SCALE (REG_BR_PROB_BASE, scale_main);
scale_act = combine_probabilities (scale_main, prob_pass_main);
-#ifdef KELVIN_NOISE
- fprintf(stderr,
- "scale_act computed from combine_probabilities: %d\n",
- scale_act);
-#endif
}
else
{
@@ -1860,10 +1738,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
for (i = 0; i < ndupl; i++)
scale_main = combine_probabilities (scale_main, scale_step[i]);
scale_act = REG_BR_PROB_BASE - prob_pass_thru;
-#ifdef KELVIN_NOISE
- fprintf(stderr, "scale_act computed from prob_pass_thru: %d\n",
- scale_act);
-#endif
}
for (i = 0; i < ndupl; i++)
gcc_assert (scale_step[i] >= 0 && scale_step[i] <= REG_BR_PROB_BASE);
@@ -1894,7 +1768,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
spec_edges[SE_ORIG] = orig;
spec_edges[SE_LATCH] = latch_edge;
-#ifdef KELVIN_PATCH
/* Recompute the loop body frequencies. */
basic_block my_header = loop->header;
int sum_incoming_frequencies = 0;
@@ -1911,7 +1784,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
(int) (EDGE_FREQUENCY (predecessor) * exit_ratio + 5000) / 10000;
}
increment_loop_frequencies (loop, my_header, sum_incoming_frequencies);
-#endif
place_after = e->src;
for (j = 0; j < ndupl; j++)
{
@@ -1922,19 +1794,8 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
copy_bbs (bbs, n, new_bbs, spec_edges, 2, new_spec_edges, loop,
place_after, true);
-#ifdef KELVIN_NOISE
- for (unsigned int w = 0; w < n; w++)
- {
- fprintf(stderr,
- "new_bbs[%d] is basic block %d, with frequency: %d\n",
- w, new_bbs[w]->index, new_bbs[w]->frequency);
- }
-#endif
-
-#ifdef KELVIN_PATCH
int place_after_frequency = place_after->frequency;
basic_block saved_place_after = place_after;
-#endif
place_after = new_spec_edges[SE_LATCH]->src;
if (flags & DLTHE_RECORD_COPY_NUMBER)
@@ -1984,21 +1845,15 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
e = new_spec_edges[SE_LATCH];
}
-#ifdef KELVIN_PATCH
zero_partial_loop_frequencies (loop, saved_place_after);
increment_loop_frequencies (loop,
saved_place_after, place_after_frequency);
-#endif
/* Record exit edge in this copy. */
if (orig && bitmap_bit_p (wont_exit, j + 1))
{
if (to_remove)
to_remove->safe_push (new_spec_edges[SE_ORIG]);
-#ifdef KELVIN_PATCH
set_zero_probability (loop, new_spec_edges[SE_ORIG]);
-#else
- set_zero_probability (new_spec_edges[SE_ORIG]);
-#endif
/* Scale the frequencies of the blocks dominated by the exit. */
if (bbs_to_scale)
{
@@ -2021,21 +1876,8 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
/* Set counts and frequencies. */
if (flags & DLTHE_FLAG_UPDATE_FREQ)
{
-#ifdef KELVIN_NOISE
- fprintf(stderr, "(flags & DLTHE_FLAG_UPDATE_FREQ): scale_act: %d\n",
- scale_act);
-#endif
scale_bbs_frequencies_int (new_bbs, n, scale_act, REG_BR_PROB_BASE);
scale_act = combine_probabilities (scale_act, scale_step[j]);
-
-#ifdef KELVIN_NOISE
- for (unsigned int w = 0; w < n; w++)
- {
- fprintf(stderr,
- "after scaling, new_bbs[%d] has frequency: %d\n",
- w, new_bbs[w]->frequency);
- }
-#endif
}
}
free (new_bbs);
@@ -2052,18 +1894,8 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
if (bbs_to_scale)
{
EXECUTE_IF_SET_IN_BITMAP (bbs_to_scale, 0, i, bi)
- {
-#ifdef KELVIN_NOISE
- fprintf(stderr, " scaling bbs[%d] because in set from %d to ",
- i, bbs[i]->frequency);
-#endif
- scale_bbs_frequencies_int (bbs + i, 1, scale_after_exit,
- REG_BR_PROB_BASE);
-#ifdef KELVIN_NOISE
- fprintf(stderr, " %d, scale factor: %d\n",
- bbs[i]->frequency, scale_after_exit);
-#endif
- }
+ scale_bbs_frequencies_int (bbs + i, 1, scale_after_exit,
+ REG_BR_PROB_BASE);
}
}
@@ -2073,14 +1905,6 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
if (flags & DLTHE_FLAG_UPDATE_FREQ)
{
scale_bbs_frequencies_int (bbs, n, scale_main, REG_BR_PROB_BASE);
-#ifdef KELVIN_NOISE
- fprintf(stderr,
- " because DLTHE_FLAG_UPDATE, blocks scaled by scale_main: %d\n",
- scale_main);
- for (unsigned int w = 0; w < n; w++)
- fprintf(stderr, " block[%d] with index %d, scaled to freq %d\n",
- w, bbs[w]->index, bbs[w]->frequency);
-#endif
free (scale_step);
}
@@ -2110,19 +1934,11 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e,
free (bbs);
BITMAP_FREE (bbs_to_scale);
-#ifdef KELVIN_PATCH
-#ifdef KELVIN_NOISE
- fprintf(stderr, "At bottom of duplicate_loop_to_header_edge()\n");
- kdn_dump_all_blocks (stderr, loop);
-#endif
-
/* The call to check_loop_frequency_integrity checks for consistency
of predecessor frequencies with the frequency of the node they
precede. */
if (flag_checking)
check_loop_frequency_integrity (loop);
-#endif
-
return true;
}
diff --git a/gcc/cfgloopmanip.h b/gcc/cfgloopmanip.h
index 81f4cf02d40..4dac7b85f99 100644
--- a/gcc/cfgloopmanip.h
+++ b/gcc/cfgloopmanip.h
@@ -60,10 +60,7 @@ extern void force_single_succ_latches (void);
struct loop * loop_version (struct loop *, void *,
basic_block *, unsigned, unsigned, unsigned, bool);
-#define KELVIN_PATCH
-#ifdef KELVIN_PATCH
extern bool in_loop_p (basic_block, struct loop *);
extern void zero_loop_frequencies (struct loop *);
extern void increment_loop_frequencies (struct loop *, basic_block, int);
-#endif
#endif /* GCC_CFGLOOPMANIP_H */
diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c
index e171b4c4f16..1c9a159ed31 100644
--- a/gcc/loop-iv.c
+++ b/gcc/loop-iv.c
@@ -70,10 +70,6 @@ along with GCC; see the file COPYING3. If not see
#include "diagnostic-core.h"
#include "dumpfile.h"
#include "rtl-iter.h"
-#define KELVIN_NOISE
-#ifdef KELVIN_NOISE
-#include "kelvin-debugs.c"
-#endif
/* Possible return values of iv_get_reaching_def. */
@@ -1881,25 +1877,6 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr)
regset altered, this_altered;
edge e;
-#ifdef KELVIN_NOISE
- fprintf(stderr, "simplify_using_initial_values() for loop ");
- kdn_dump_loop(stderr, loop);
- switch (op)
- {
- case AND:
- fprintf(stderr, "Combinator is AND\n");
- break;
-
- case IOR:
- fprintf(stderr, "Combinator is IOR\n");
- break;
-
- default:
- fprintf(stderr, "Unexpected combinator\n");
- }
- fprintf(stderr, "Expression is\n");
- kdn_dump_rtl_insns(stderr, *expr);
-#endif
if (!*expr)
return;
@@ -2365,18 +2342,12 @@ iv_number_of_iterations (struct loop *loop, rtx_insn *insn, rtx condition,
if noloop_assumptions then the loop does not roll
if infinite then this exit is never used */
-#ifdef KELVIN_NOISE
- fprintf(stderr, "iv_number_of_iterations()\n");
-#endif
desc->assumptions = NULL_RTX;
desc->noloop_assumptions = NULL_RTX;
desc->infinite = NULL_RTX;
desc->simple_p = true;
desc->const_iter = false;
-#ifdef KELVIN_NOISE
- fprintf(stderr, " ... setting niter_expr to NULL_RTX\n");
-#endif
desc->niter_expr = NULL_RTX;
cond = GET_CODE (condition);
@@ -2717,9 +2688,6 @@ iv_number_of_iterations (struct loop *loop, rtx_insn *insn, rtx condition,
tmp = simplify_gen_binary (UDIV, mode, tmp1, gen_int_mode (d, mode));
inv = inverse (s, size);
tmp = simplify_gen_binary (MULT, mode, tmp, gen_int_mode (inv, mode));
-#ifdef KELVIN_NOISE
- fprintf(stderr, " ... setting niter_expr to simplify_gen_binary()\n");
-#endif
desc->niter_expr = simplify_gen_binary (AND, mode, tmp, bound);
}
else
@@ -2822,15 +2790,9 @@ iv_number_of_iterations (struct loop *loop, rtx_insn *insn, rtx condition,
desc->noloop_assumptions =
alloc_EXPR_LIST (0, assumption, desc->noloop_assumptions);
delta = simplify_gen_binary (UDIV, mode, delta, step);
-#ifdef KELVIN_NOISE
- fprintf(stderr, " ... setting niter_expr to delta\n");
-#endif
desc->niter_expr = delta;
}
-#ifdef KELVIN_NOISE
- fprintf(stderr, " ... saving niter_expr to old_niter\n");
-#endif
old_niter = desc->niter_expr;
simplify_using_initial_values (loop, AND, &desc->assumptions);
@@ -2896,9 +2858,6 @@ iv_number_of_iterations (struct loop *loop, rtx_insn *insn, rtx condition,
desc->niter_expr = old_niter;
}
-#ifdef KELVIN_NOISE
- fprintf(stderr, " ... returning (non-zero)\n");
-#endif
return;
zero_iter_simplify:
@@ -2916,16 +2875,10 @@ zero_iter:
record_niter_bound (loop, 0, true, true);
desc->noloop_assumptions = NULL_RTX;
desc->niter_expr = const0_rtx;
-#ifdef KELVIN_NOISE
- fprintf(stderr, " ... returning (zero)\n");
-#endif
return;
fail:
desc->simple_p = false;
-#ifdef KELVIN_NOISE
- fprintf(stderr, " ... returning (failure)\n");
-#endif
return;
}
diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c
index 641b0f27960..9bff1ea6a38 100644
--- a/gcc/loop-unroll.c
+++ b/gcc/loop-unroll.c
@@ -45,10 +45,6 @@ along with GCC; see the file COPYING3. If not see
#include "target.h"
#include "dumpfile.h"
-#define KELVIN_NOISE
-#ifdef KELVIN_NOISE
-#include "kelvin-debugs.c"
-#endif
/* This pass performs loop unrolling. We only perform this
optimization on innermost loops (with single exception) because
the impact on performance is greatest here, and we want to avoid
@@ -288,20 +284,12 @@ unroll_loops (int flags)
struct loop *loop;
bool changed = false;
-#ifdef KELVIN_NOISE
- fprintf(stderr, "In unroll_loops(0x%x)\n", flags);
-#endif
/* Now decide rest of unrolling. */
decide_unrolling (flags);
/* Scan the loops, inner ones first. */
FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
{
-#ifdef KELVIN_NOISE
- fprintf(stderr, "In unroll_loop, looking at loop ");
- kdn_dump_loop(stderr, loop);
- kdn_dump_all_blocks(stderr, loop);
-#endif
/* And perform the appropriate transformations. */
switch (loop->lpt_decision.decision)
{
@@ -367,11 +355,6 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
struct niter_desc *desc;
widest_int iterations;
-#ifdef KELVIN_NOISE
- fprintf(stderr, "decide_unroll_constant_iterations (loop %d)\n", loop->num);
- fprintf(stderr, " UAP_UNROLL flag is %s\n",
- (flags & UAP_UNROLL)? "on": "off");
-#endif
if (!(flags & UAP_UNROLL))
{
/* We were not asked to, just return back silently. */
@@ -396,9 +379,6 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
if (targetm.loop_unroll_adjust)
nunroll = targetm.loop_unroll_adjust (nunroll, loop);
-#ifdef KELVIN_NOISE
- fprintf(stderr, " after some calculations, nunroll is %d\n", nunroll);
-#endif
/* Skip big loops. */
if (nunroll <= 1)
{
@@ -416,13 +396,6 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
if (dump_file)
fprintf (dump_file,
";; Unable to prove that the loop iterates constant times\n");
-#ifdef KELVIN_NOISE
- fprintf(stderr,
- " abandoning all hope, can't prove constant iterations\n");
- fprintf(stderr,
- " simple_p: %d, const_iter: %d, assumptions: %d\n",
- desc->simple_p, desc->const_iter, (desc->assumptions != NULL));
-#endif
return;
}
@@ -437,14 +410,8 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
{
if (dump_file)
fprintf (dump_file, ";; Not unrolling loop, doesn't roll\n");
-#ifdef KELVIN_NOISE
- fprintf(stderr, " abandoning effort, loop doesn't roll\n");
-#endif
return;
}
-#ifdef KELVIN_NOISE
- fprintf(stderr, " committing to constant unroll, TBD iteration count\n");
-#endif
/* Success; now compute number of iterations to unroll. We alter
nunroll so that as few as possible copies of loop body are
@@ -474,9 +441,6 @@ decide_unroll_constant_iterations (struct loop *loop, int flags)
best_unroll = i;
}
}
-#ifdef KELVIN_NOISE
- fprintf(stderr, " returning, best_unroll is %d\n", best_unroll);
-#endif
loop->lpt_decision.decision = LPT_UNROLL_CONSTANT;
loop->lpt_decision.times = best_unroll;
}
@@ -622,7 +586,6 @@ unroll_loop_constant_iterations (struct loop *loop)
/* Now unroll the loop. */
opt_info_start_duplication (opt_info);
-#ifdef KELVIN_PATCH
ok = duplicate_loop_to_header_edge (loop, loop_latch_edge (loop),
max_unroll,
wont_exit, desc->out_edge,
@@ -630,16 +593,6 @@ unroll_loop_constant_iterations (struct loop *loop)
opt_info
? DLTHE_RECORD_COPY_NUMBER
: 0);
-#else
- ok = duplicate_loop_to_header_edge (loop, loop_latch_edge (loop),
- max_unroll,
- wont_exit, desc->out_edge,
- &remove_edges,
- DLTHE_FLAG_UPDATE_FREQ
- | (opt_info
- ? DLTHE_RECORD_COPY_NUMBER
- : 0));
-#endif
gcc_assert (ok);
if (opt_info)
@@ -912,7 +865,6 @@ unroll_loop_runtime_iterations (struct loop *loop)
bool exit_at_end = loop_exit_at_end_p (loop);
struct opt_info *opt_info = NULL;
bool ok;
-#ifdef KELVIN_PATCH
int header_frequency;
int sum_incoming_frequencies;
int exit_multiplier;
@@ -920,38 +872,15 @@ unroll_loop_runtime_iterations (struct loop *loop)
edge predecessor;
header_frequency = loop->header->frequency;
-#ifdef KELVIN_NOISE
- fprintf(stderr, "unroll_loop_runtime_iterations, loop header block: %d\n",
- loop->header->index);
- fprintf(stderr, " header frequency: %d\n", header_frequency);
-#endif
sum_incoming_frequencies = 0;
FOR_EACH_EDGE (predecessor, ei, loop->header->preds)
{
if (!in_loop_p (predecessor->src, loop))
- {
-#ifdef KELVIN_NOISE
- fprintf(stderr, " predecessor %d has frequency %d\n",
- predecessor->src->index, EDGE_FREQUENCY (predecessor));
-#endif
- sum_incoming_frequencies += EDGE_FREQUENCY (predecessor);
- }
+ sum_incoming_frequencies += EDGE_FREQUENCY (predecessor);
}
exit_multiplier = (header_frequency * 10000) / sum_incoming_frequencies;
-#ifdef KELVIN_NOISE
- fprintf(stderr, "unroll_loop_runtime_iterations, exit_multiplier is %d\n",
- exit_multiplier);
- fprintf(stderr, " computed from sum_incoming_frequencies: %d\n",
- sum_incoming_frequencies);
- fprintf(stderr,
- " expect value of 111111 for typical run-time bounded loop\n");
- fprintf(stderr,
- " expect value of 990099 for typical compile-time bounded loop\n");
-#endif
-#endif
-
if (flag_split_ivs_in_unroller
|| flag_variable_expansion_in_unroller)
opt_info = analyze_insns_in_loop (loop);
@@ -1011,17 +940,9 @@ unroll_loop_runtime_iterations (struct loop *loop)
end_sequence ();
unshare_all_rtl_in_chain (init_code);
-#ifdef KELVIN_NOISE
- fprintf(stderr, "before preconditioning the loop, preheader dest is\n");
- kdn_dump_block(stderr, loop_preheader_edge (loop)->dest);
-#endif
/* Precondition the loop. */
split_edge_and_insert (loop_preheader_edge (loop), init_code);
-#ifdef KELVIN_NOISE
- fprintf(stderr, "after preconditioning the loop, preheader dest is\n");
- kdn_dump_block(stderr, loop_preheader_edge (loop)->dest);
-#endif
auto_vec<edge> remove_edges;
wont_exit = sbitmap_alloc (max_unroll + 2);
@@ -1039,56 +960,31 @@ unroll_loop_runtime_iterations (struct loop *loop)
1, wont_exit, desc->out_edge,
&remove_edges,
DLTHE_FLAG_UPDATE_FREQ);
-#ifdef KELVIN_NOISE
- /* I think the problem occurs because we duplicate the loop body
- which includes an exit edge, and then we remove the exit edge
- without redistributing its frequency and probability to the other
- edges. This problem occurs within duplicate_loop_to_header_edge. */
- fprintf(stderr, " after peeling first copy of loop body, ezc_switch is\n");
- kdn_dump_block(stderr, ezc_swtch);
- fprintf(stderr, " and its successors are\n");
- edge outgoing;
- FOR_EACH_EDGE (outgoing, ei, ezc_swtch->succs)
- {
- fprintf(stderr, " successor block is\n");
- kdn_dump_block(stderr, outgoing->dest);
- }
-#endif
gcc_assert (ok);
/* Record the place where switch will be built for preconditioning. */
swtch = split_edge (loop_preheader_edge (loop));
-#ifdef KELVIN_NOISE
- fprintf(stderr, " after splitting edge, swtch is\n");
- kdn_dump_block(stderr, swtch);
-#endif
-#ifdef KELVIN_PATCH
int iter_freq, new_freq;
iter_freq = new_freq = swtch->frequency / (n_peel+1);
swtch->frequency = new_freq;
-#endif
for (i = 0; i < n_peel; i++)
{
/* Peel the copy. */
bitmap_clear (wont_exit);
if (i != n_peel - 1 || !last_may_exit)
bitmap_set_bit (wont_exit, 1);
-#ifdef KELVIN_PATCH
int saved_header_frequency = loop->header->frequency;
zero_loop_frequencies (loop);
int new_header_freq = (saved_header_frequency / (n_peel + 1)) * (i + 1);
increment_loop_frequencies (loop, loop->header, new_header_freq);
-#endif
ok = duplicate_loop_to_header_edge (loop, loop_preheader_edge (loop),
1, wont_exit, desc->out_edge,
&remove_edges,
DLTHE_FLAG_UPDATE_FREQ);
-#ifdef KELVIN_PATCH
zero_loop_frequencies (loop);
increment_loop_frequencies (loop, loop->header, saved_header_frequency);
-#endif
gcc_assert (ok);
/* Create item for switch. */
@@ -1096,10 +992,6 @@ unroll_loop_runtime_iterations (struct loop *loop)
p = REG_BR_PROB_BASE / (i + 2);
preheader = split_edge (loop_preheader_edge (loop));
-#ifdef KELVIN_NOISE
- fprintf(stderr, " after split_edge, preheader is\n");
- kdn_dump_block(stderr, preheader);
-#endif
branch_code = compare_and_jump_seq (copy_rtx (niter), GEN_INT (j), EQ,
block_label (preheader), p,
NULL);
@@ -1110,16 +1002,11 @@ unroll_loop_runtime_iterations (struct loop *loop)
swtch = split_edge_and_insert (single_pred_edge (swtch), branch_code);
set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
-#ifdef KELVIN_PATCH
single_succ_edge (swtch)->probability = REG_BR_PROB_BASE - p;
-#else
- single_pred_edge (swtch)->probability = REG_BR_PROB_BASE - p;
-#endif
e = make_edge (swtch, preheader,
single_succ_edge (swtch)->flags & EDGE_IRREDUCIBLE_LOOP);
e->count = RDIV (preheader->count * REG_BR_PROB_BASE, p);
e->probability = p;
-#ifdef KELVIN_PATCH
new_freq = new_freq + iter_freq;
swtch->frequency = new_freq;
@@ -1132,7 +1019,6 @@ unroll_loop_runtime_iterations (struct loop *loop)
prehead_frequency += the_edge_frequency;
}
preheader->frequency = prehead_frequency;
-#endif
}
if (extra_zero_check)
@@ -1164,7 +1050,6 @@ unroll_loop_runtime_iterations (struct loop *loop)
bitmap_clear_bit (wont_exit, may_exit_copy);
opt_info_start_duplication (opt_info);
-#ifdef KELVIN_PATCH
{
/* Recompute the loop body frequencies. */
zero_loop_frequencies (loop);
@@ -1213,8 +1098,6 @@ unroll_loop_runtime_iterations (struct loop *loop)
sum_incoming_frequencies /= 10000;
increment_loop_frequencies (loop, my_header, sum_incoming_frequencies);
}
-#endif
-#ifdef KELVIN_PATCH
ok = duplicate_loop_to_header_edge (loop, loop_latch_edge (loop),
max_unroll,
wont_exit, desc->out_edge,
@@ -1222,16 +1105,6 @@ unroll_loop_runtime_iterations (struct loop *loop)
opt_info
? DLTHE_RECORD_COPY_NUMBER
: 0);
-#else
- ok = duplicate_loop_to_header_edge (loop, loop_latch_edge (loop),
- max_unroll,
- wont_exit, desc->out_edge,
- &remove_edges,
- DLTHE_FLAG_UPDATE_FREQ
- | (opt_info
- ? DLTHE_RECORD_COPY_NUMBER
- : 0));
-#endif
gcc_assert (ok);
if (opt_info)