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]

Fix for aborts in loop_iterations


With my last loop change, the compiler started aborting in loop_iterations.
Due to the transformations which are now done, a register that didn't
exist before loop started can now be an iteration variable.  loop_iterations
believes that this is impossible.

Here's a small test case which I'm going to install as compile/991127-1.c
(it's stripped down from a part of newlib and not recognizable anymore...)

extern void foo (int *);

static void bar (char *buf)
{
    int a;
    foo (&a);
    while (a > 0) {
	*buf++ = '0';
	a--;
    }
}

The simplest fix for now is to replace the abort with a return 0 to indicate
that we don't know how to handle such a case.  A better fix would be to
somehow keep the register information uptodate, but I don't see a good way
to achieve that short of running reg_scan after processing each loop.

Bernd

	* unroll.c (loop_iterations): Don't abort if regno of iteration var
	is too high; just return 0.

diff -c -p -r1.78 unroll.c
*** unroll.c	1999/11/12 20:44:13	1.78
--- unroll.c	1999/11/27 13:14:31
*************** loop_iterations (loop_start, loop_end, l
*** 3687,3697 ****
        return 0;
      }
  
!   /* The only new registers that care created before loop iterations are
!      givs made from biv increments, so this should never occur.  */
! 
    if ((unsigned) REGNO (iteration_var) >= reg_iv_type->num_elements)
!     abort ();
  
    iteration_info (iteration_var, &initial_value, &increment,
  		  loop_start, loop_end);
--- 3687,3695 ----
        return 0;
      }
  
!   /* This can happen due to optimization in load_mems.  */
    if ((unsigned) REGNO (iteration_var) >= reg_iv_type->num_elements)
!     return 0;
  
    iteration_info (iteration_var, &initial_value, &increment,
  		  loop_start, loop_end);


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