This is the mail archive of the gcc-patches@gcc.gnu.org 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] PR/17635



On Sep 24, 2004, at 2:54 PM, Richard Henderson wrote:


On Fri, Sep 24, 2004 at 09:49:34AM -0700, Devang Patel wrote:
	* tree-if-conv.c (if_convertable_loop_p): Check for loop with zero
exits.

It strikes me as likely that you're papering over some bug. I don't see any reason why a zero exit loop shouldn't be handled by your pass.

If-conversion pass does not allow loops with non-empty basic blocks after exit edge. So latch is either empty or bb with exit edge. However, in this case there is no exit and latch is non-empty.

Alternatives
1) Reject such loops
2) Take care of non-empty latch in such cases and update
   loop structure after blocks are merged.

Following patch implements 2). Bootstrapped on powerpc-darwin
with -ftree-vectorize (to enable if-conversion during bootstrap).
DejaGNU run is in progress.

     * tree-if-conv.c (process_phi_nodes): Process latch block.
	(combine_blocks): Process latch block and update loop structure.

thoughts?
-
Devang

Index: tree-if-conv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-if-conv.c,v
retrieving revision 2.10
diff -Idpatel.pbxuser -c -3 -p -r2.10 tree-if-conv.c
*** tree-if-conv.c      28 Sep 2004 07:59:51 -0000      2.10
--- tree-if-conv.c      5 Oct 2004 16:03:18 -0000
*************** process_phi_nodes (struct loop *loop)
*** 815,821 ****
        basic_block true_bb = NULL;
        bb = ifc_bbs[i];

!       if (bb == loop->header || bb == loop->latch)
        continue;

        phi = phi_nodes (bb);
--- 815,821 ----
        basic_block true_bb = NULL;
        bb = ifc_bbs[i];

!       if (bb == loop->header)
        continue;

        phi = phi_nodes (bb);
*************** combine_blocks (struct loop *loop)
*** 863,871 ****

bb = ifc_bbs[i];

-       if (bb == loop->latch)
-       continue;
-
        if (!exit_bb && bb_with_exit_edge_p (bb))
          exit_bb = bb;

--- 863,868 ----
*************** combine_blocks (struct loop *loop)
*** 891,896 ****
--- 888,896 ----
          continue;
        }

+ if (bb == loop->latch && empty_block_p (bb))
+ continue;
+
/* It is time to remove this basic block. First remove edges. */
while (EDGE_COUNT (bb->succs) > 0)
ssa_remove_edge (EDGE_SUCC (bb, 0));
*************** combine_blocks (struct loop *loop)
*** 921,926 ****
--- 921,928 ----
delete_from_dominance_info (CDI_POST_DOMINATORS, bb);


/* Remove basic block. */
+ if (bb == loop->latch)
+ loop->latch = merge_target_bb;
remove_bb_from_loops (bb);
expunge_block (bb);
}
*************** combine_blocks (struct loop *loop)
*** 928,934 ****
/* Now if possible, merge loop header and block with exit edge.
This reduces number of basic blocks to 2. Auto vectorizer addresses
loops with two nodes only. FIXME: Use cleanup_tree_cfg(). */
! if (exit_bb != loop->latch && empty_block_p (loop->latch))
{
if (can_merge_blocks_p (loop->header, exit_bb))
{
--- 930,939 ----
/* Now if possible, merge loop header and block with exit edge.
This reduces number of basic blocks to 2. Auto vectorizer addresses
loops with two nodes only. FIXME: Use cleanup_tree_cfg(). */
! if (exit_bb
! && loop->header != loop->latch
! && exit_bb != loop->latch
! && empty_block_p (loop->latch))
{
if (can_merge_blocks_p (loop->header, exit_bb))
{



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