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]

fix g++.dg/opt/mmx1.C regression


Caught by Jan's new verify_loop_info checks.

The number of iterations in the loop really is 0xffffffff, which
passed the unsigned comparison in the if, but was rendered as a
signed division in the computation.  Which resulted in negative
frequency counts.


r~


        * loop.c (strength_reduce): Compute number of iterations as
        unsigned HOST_WIDE_INT.

Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.390
diff -c -p -d -r1.390 loop.c
*** loop.c	2002/02/27 15:03:05	1.390
--- loop.c	2002/03/10 23:45:11
*************** strength_reduce (loop, flags)
*** 5225,5237 ****
    /* In case number of iterations is known, drop branch prediction note
       in the branch.  Do that only in second loop pass, as loop unrolling
       may change the number of iterations performed.  */
!   if ((flags & LOOP_BCT)
!       && loop_info->n_iterations / loop_info->unroll_number > 1)
      {
!       int n = loop_info->n_iterations / loop_info->unroll_number;
!       predict_insn (PREV_INSN (loop->end),
! 		    PRED_LOOP_ITERATIONS,
! 		    REG_BR_PROB_BASE - REG_BR_PROB_BASE / n);
      }
  
    if (loop_dump_stream)
--- 5225,5237 ----
    /* In case number of iterations is known, drop branch prediction note
       in the branch.  Do that only in second loop pass, as loop unrolling
       may change the number of iterations performed.  */
!   if (flags & LOOP_BCT)
      {
!       unsigned HOST_WIDE_INT n
! 	= loop_info->n_iterations / loop_info->unroll_number;
!       if (n > 1)
! 	predict_insn (PREV_INSN (loop->end), PRED_LOOP_ITERATIONS,
! 		      REG_BR_PROB_BASE - REG_BR_PROB_BASE / n);
      }
  
    if (loop_dump_stream)


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