This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cfg merge part 17 - loop datastructure updates
- From: Richard Henderson <rth at redhat dot com>
- To: Jan Hubicka <jh at suse dot cz>
- Cc: gcc-patches at gcc dot gnu dot org, gcc-pdo at atrey dot karlin dot mff dot cuni dot cz, m dot hayes at elec dot canterbury dot ac dot nz
- Date: Thu, 30 May 2002 13:06:03 -0700
- Subject: Re: cfg merge part 17 - loop datastructure updates
- References: <20020513130251.GJ17596@atrey.karlin.mff.cuni.cz>
On Mon, May 13, 2002 at 03:02:51PM +0200, Jan Hubicka wrote:
> + /* In new loop representation, we store only pointers here. */
> + struct loop **parray;
Well, I should hope so, since this is a pointer type.
Aside from that, the comment is less than enlightening.
> + /* Ratio of frequencies of edges so that one of more latch edges is
> + considered to belong to inner loop with same header. */
> + #define HEAVY_EDGE_RATIO 8
> /* Check all nodes within the loop to see if there are any
> successors not in the loop. Note that a node may have multiple
> exiting edges ????? A node can have one jumping edge and one fallthru
> edge so only one of these can exit the loop. */
The ??? comment is wrong. A node can be a switch statement and
lots of edges can exit the loop. A node can throw an exception
and have oodles of edges leaving the loop. The code seems to
handle the arbitrary case though.
Question: wouldn't it be better to use a varray for the exit_edges
so that you don't have to test each edge twice?
> + if (HEADER_BLOCK (ENTRY_BLOCK_PTR->succ->dest))
> + {
> + rtx insn;
> + edge fallthru, next_e;
> + basic_block bb;
> + /* We could not redirect edges freely here. On the other hand,
> + we know that no abnormal edge enters this block, so we can simply
> + split it into two... */
> + bb = ENTRY_BLOCK_PTR->succ->dest;
> + insn = PREV_INSN (first_insn_after_basic_block_note (bb));
> + fallthru = split_block (bb, insn);
> +
> + /* And redirect all edges to second part. */
> + for (e = fallthru->src->pred; e; e = next_e)
> + {
> + next_e = e->pred_next;
> + if (e->src == ENTRY_BLOCK_PTR)
> + continue;
> + fallthru->src->frequency -= EDGE_FREQUENCY (e);
> + fallthru->src->count -= e->count;
> + if (fallthru->src->frequency < 0)
> + fallthru->src->frequency = 0;
> + if (fallthru->src->count < 0)
> + fallthru->src->count = 1;
> + redirect_edge_with_latch_update (e, fallthru->dest);
> + }
Surely this is the same as split_edge(ENTRY_BLOCK_PTR->succ)?
Or, if additional code needed for latch/header updates, can still
be greatly simplified.
> + flow_bb_inside_loop_p (loop, bb)
> + if (bb == ENTRY_BLOCK_PTR || bb == EXIT_BLOCK_PTR) return 0;
Return on next line.
> + /* Checks that LOOPS are allright:
> + -- sizes of loops are allright
> + -- results of get_loop_body really belong to the loop
> + -- loop header have just single entry edge and single latch edge
> + -- loop latches have only single successor that is header of their loop
> + -- sanity of frequencies */
> + void verify_loop_structure (loops, flags)
Function name on next line.
> + for (e = loop->header->pred; e->src == loop->latch; e = e->pred_next);
continue on next line.
r~