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] for PR14692


Hello,

it may happen that the comparison created in may_unswitch_on have both
sides constant; we cannot return this since we would be unable to
determine the mode of operands.

This patch fixes it by folding the result and returning just
const0_rtx/const_true_rtx in this case.

Bootstrapped & regtested on i686 (with -funswitch-loops).

Zdenek

	PR 14692
	* loop-unswitch.c (may_unswitch_on): Try folding the result.
	(unswitch_single_loop): Work correctly when may_unswitch_on
	returns a folded constant.

Index: loop-unswitch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-unswitch.c,v
retrieving revision 1.16
diff -c -3 -p -r1.16 loop-unswitch.c
*** loop-unswitch.c	24 Feb 2004 23:39:55 -0000	1.16
--- loop-unswitch.c	9 May 2004 21:20:52 -0000
*************** unswitch_loops (struct loops *loops)
*** 174,180 ****
  static rtx
  may_unswitch_on (basic_block bb, struct loop *loop, rtx *cinsn)
  {
!   rtx test, at, insn, op[2];
    struct rtx_iv iv;
    unsigned i;
    enum machine_mode mode;
--- 174,180 ----
  static rtx
  may_unswitch_on (basic_block bb, struct loop *loop, rtx *cinsn)
  {
!   rtx test, at, insn, op[2], stest;
    struct rtx_iv iv;
    unsigned i;
    enum machine_mode mode;
*************** may_unswitch_on (basic_block bb, struct 
*** 233,238 ****
--- 233,244 ----
        return test;
      }
  
+   stest = simplify_gen_relational (GET_CODE (test), SImode,
+ 				   mode, op[0], op[1]);
+   if (stest == const0_rtx
+       || stest == const_true_rtx)
+     return stest;
+ 
    return canon_condition (gen_rtx_fmt_ee (GET_CODE (test), SImode,
  					  op[0], op[1]));
  }
*************** unswitch_single_loop (struct loops *loop
*** 262,268 ****
    basic_block *bbs;
    struct loop *nloop;
    unsigned i;
!   rtx cond, rcond, conds, rconds, acond, cinsn = NULL_RTX;
    int repeat;
    edge e;
  
--- 268,274 ----
    basic_block *bbs;
    struct loop *nloop;
    unsigned i;
!   rtx cond, rcond = NULL_RTX, conds, rconds, acond, cinsn = NULL_RTX;
    int repeat;
    edge e;
  
*************** unswitch_single_loop (struct loops *loop
*** 331,343 ****
  	  return;
  	}
  
!       rcond = reversed_condition (cond);
!       if (rcond)
! 	rcond = canon_condition (rcond);
! 
!       /* Check whether the result can be predicted.  */
!       for (acond = cond_checked; acond; acond = XEXP (acond, 1))
! 	simplify_using_condition (XEXP (acond, 0), &cond, NULL);
  
        if (cond == const_true_rtx)
  	{
--- 337,353 ----
  	  return;
  	}
  
!       if (cond != const0_rtx
! 	  && cond != const_true_rtx)
! 	{
! 	  rcond = reversed_condition (cond);
! 	  if (rcond)
! 	    rcond = canon_condition (rcond);
! 
! 	  /* Check whether the result can be predicted.  */
! 	  for (acond = cond_checked; acond; acond = XEXP (acond, 1))
! 	    simplify_using_condition (XEXP (acond, 0), &cond, NULL);
! 	}
  
        if (cond == const_true_rtx)
  	{


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