This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] for PR 18601

Hi Zdenek,

> 	PR tree-optimization/18601
> 	* tree-cfg.c (thread_jumps, phi_alternatives_equal,
> 	thread_jumps_from_bb): Removed.
> 	(tree_forwarder_block_p): Do not consider blocks that are its own
> 	successors forwarders.
> 	(cleanup_forwarder_blocks, remove_forwarder_block): New functions.
> 	(cleanup_tree_cfg): Use cleanup_forwarder_blocks instead of
> 	thread_jumps.

Wow, great!  It's good that you are moving our focus to forwarder
blocks from non-forwarder blocks.

Without this patch, we focus on forwarder blocks while constructing
the worklist, but when it comes to draining the worklist, the focus
moves to non-forwarder blocks.  At that point, we know we can thread
at least one outgoing edge out of each non-forwarder block in the
worklist, but it is probably often the case that none of the other
outgoing edges can be threaded, wasting a lot of time there.

With your patch, we know that all non-abnormal incoming edges to a
forwarder block can be threaded unless they are blocked by a PHI node.

> !   /* If there are phi nodes in DEST, and some of the blocks that are
> !      predecessors of BB are also predecessors of DEST, check that the
> !      phi node arguments match.  Also record the list of arguments that
> !      come from SUCC edge, to avoid calling PHI_ARG_DEF_FROM_EDGE
> !      too much.  */
> !   n = 0;
> !   for (phi = phi_nodes (dest); phi; phi = PHI_CHAIN (phi))
> !     n++;
> !   defs = xmalloc (n * sizeof (tree));

I don't know if this is necessary because, given an edge, you can now
look up a PHI argument in constant time, so you can copy PHI arguments
like so

  /* Create arguments for the phi nodes, since the edge was not
     here before.  */
  for (phi = phi_nodes (dest); phi; phi = PHI_CHAIN (phi))
      tree def = PHI_ARG_DEF (phi, succ->dest_idx);
      add_phi_arg (&phi, def, s);

thereby avoiding malloc.

Kazu Hirata

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]