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]

[PATCH] Teach find_cond_trap in ifcvt.c how to update the CFG


Hi,

This is another step towards making ifcvt work in cfglayout mode.

In this patch, find_cond_trap learns how to maintain the CFG.

Bootstrapped&tested on x86_64-unknown-linux-gnu, but this target
dos not have conditional_trap.  Hence, also bootstrapped&tested
on ia64-unknown-linux-gnu.

OK for the trunk?

Gr.
Steven


	* ifcvt.c (find_cond_trap): Update CFG manually instead of
	using merge_if_block.

Index: ifcvt.c
===================================================================
*** ifcvt.c	(revision 120524)
--- ifcvt.c	(working copy)
*************** find_cond_trap (basic_block test_bb, edg
*** 3209,3229 ****
    /* Delete the trap block if possible.  */
    remove_edge (trap_bb == then_bb ? then_edge : else_edge);
    if (EDGE_COUNT (trap_bb->preds) == 0)
-     delete_basic_block (trap_bb);
- 
-   /* If the non-trap block and the test are now adjacent, merge them.
-      Otherwise we must insert a direct branch.  */
-   if (test_bb->next_bb == other_bb)
      {
!       struct ce_if_block new_ce_info;
!       delete_insn (jump);
!       memset (&new_ce_info, '\0', sizeof (new_ce_info));
!       new_ce_info.test_bb = test_bb;
!       new_ce_info.then_bb = NULL;
!       new_ce_info.else_bb = NULL;
!       new_ce_info.join_bb = other_bb;
!       merge_if_block (&new_ce_info);
      }
    else
      {
        rtx lab, newjump;
--- 3209,3222 ----
    /* Delete the trap block if possible.  */
    remove_edge (trap_bb == then_bb ? then_edge : else_edge);
    if (EDGE_COUNT (trap_bb->preds) == 0)
      {
!       delete_basic_block (trap_bb);
!       num_updated_if_blocks++;
      }
+ 
+   /* Wire together the blocks again.  */
+   if (current_ir_type () == IR_RTL_CFGLAYOUT)
+     single_succ_edge (test_bb)->flags |= EDGE_FALLTHRU;
    else
      {
        rtx lab, newjump;
*************** find_cond_trap (basic_block test_bb, edg
*** 3233,3241 ****
        LABEL_NUSES (lab) += 1;
        JUMP_LABEL (newjump) = lab;
        emit_barrier_after (newjump);
- 
-       delete_insn (jump);
      }
  
    return TRUE;
  }
--- 3226,3236 ----
        LABEL_NUSES (lab) += 1;
        JUMP_LABEL (newjump) = lab;
        emit_barrier_after (newjump);
      }
+   delete_insn (jump);
+ 
+   if (can_merge_blocks_p (test_bb, other_bb))
+     merge_blocks (test_bb, other_bb);
  
    return TRUE;
  }


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