patch unroll.c(loop_iterations) add missing break?

Graham Stott graham.stott@btinternet.com
Sun Sep 21 16:40:00 GMT 2003


All,

This is a tentative patch which has survived bootstrap x86-pc-linux-gnu but hasn't finished
regression testing yet and it'll be next weekend before I can look at the results.

The following code fragment from unroll.c(loop_iterations) looks to be missing a break
following "case GT" so it's falling into the "case NE" and thus incorrectly setting
compare_dir = 0; which means can't determine # loop iterations.

This will thus disable loop unrolling for ">" loops.

   unsigned_p = 0;
   off_by_one = 0;
   switch (comparison_code)
     {
     case LEU:
       unsigned_p = 1;
     case LE:
       compare_dir = 1;
       off_by_one = 1;
       break;
     case GEU:
       unsigned_p = 1;
     case GE:
       compare_dir = -1;
       off_by_one = -1;
       break;
     case EQ:
       /* Cannot determine loop iterations with this case.  */
       compare_dir = 0;
       break;
     case LTU:
       unsigned_p = 1;
     case LT:
       compare_dir = 1;
       break;
     case GTU:
       unsigned_p = 1;
     case GT:
       compare_dir = -1;       <<< falls into NE case!!!!
     case NE:
       compare_dir = 0;
       break;
     default:
       abort ();
     }

Adding the missing break means we'll start enable unrolling for ">" loops
so might trigger dormant bugs elsewhere in the unroller.

Cheers
Graham

ChangeLog

       * unroll.c(loop_interations)[GT]: Add missing break.

-------------------------------------------------------------------
Index: unroll.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/unroll.c,v
retrieving revision 1.201
diff -c -p -r1.201 unroll.c
*** unroll.c    21 Jul 2003 16:52:36 -0000      1.201
--- unroll.c    21 Sep 2003 16:03:44 -0000
*************** loop_iterations (struct loop *loop)
*** 3538,3543 ****
--- 3538,3544 ----
         unsigned_p = 1;
       case GT:
         compare_dir = -1;
+       break;
       case NE:
         compare_dir = 0;
         break;
------------------------------------------------------------------



More information about the Gcc-patches mailing list