This is the mail archive of the
mailing list for the GCC project.
Re: Updating the CFG on the fly?
Richard Henderson writes:
> > I'm looking at merging natural loops that share the same header and
> > need to create new postbody nodes.
> In all likelyhood you can use insert_insn_on_edge to create
> those new blocks. With a more precise description of what
> you are trying to do, I could tell for sure.
I am trying to modify the CFG so that we do not have multiple natural
loops sharing the same header block.
In the case of nested loops sharing the same header, I envisage that
the best approach is to add pre-header blocks to the inner loops, so
that the only forward edges into the header come from the pre-header.
(This will also help the loop optimizer by providing blocks for
hoisting insns out of nested loops.)
In the case of disjoint loops sharing the same header, I envisage that
a postbody node could be created that becomes the latch block of the
new merged loop. All the back edges to the shared header then become
forward edges to the postbody block.
I now see how insert_insn_on_edge can be used to create a new basic
block, but is there an easy way to redirect edges without having to
use redirect_jump and manually updating the edge table?