[PATCH] Prevent ifcvt from moving computations into loop

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Tue Jul 15 17:27:00 GMT 2003


Hello,

does someone know about some reason why the condition removed by this
patch is in find_if_case_2?  In cases like

  ---> something  ---> "else" --> "else_succ"
   /              \              /
   \              /            /
     -<- "then" -            ...

this condition causes computations from "else" block to be moved inside
the loop, which definitely is not a good idea.

Zdenek

Changelog:
	* ifcvt.c (find_if_case_2): Prevent moving computations into
	loop.

Index: ifcvt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ifcvt.c,v
retrieving revision 1.102.2.5
diff -c -3 -p -r1.102.2.5 ifcvt.c
*** ifcvt.c	25 Jan 2003 11:45:39 -0000	1.102.2.5
--- ifcvt.c	14 Jul 2003 22:01:35 -0000
*************** find_if_case_2 (test_bb, then_edge, else
*** 2779,2793 ****
    if (then_bb->index < 0)
      return FALSE;
  
!   /* ELSE is predicted or SUCC(ELSE) postdominates THEN.  */
    note = find_reg_note (test_bb->end, REG_BR_PROB, NULL_RTX);
!   if (note && INTVAL (XEXP (note, 0)) >= REG_BR_PROB_BASE / 2)
!     ;
!   else if (else_succ->dest->index < 0
! 	   || dominated_by_p (post_dominators, then_bb, 
! 			      else_succ->dest))
!     ;
!   else
      return FALSE;
  
    num_possible_if_blocks++;
--- 2779,2787 ----
    if (then_bb->index < 0)
      return FALSE;
  
!   /* ELSE is predicted.  */
    note = find_reg_note (test_bb->end, REG_BR_PROB, NULL_RTX);
!   if (!note || INTVAL (XEXP (note, 0)) < REG_BR_PROB_BASE / 2)
      return FALSE;
  
    num_possible_if_blocks++;



More information about the Gcc-patches mailing list