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]

Bug in loop opt


This triggers a bug in the loop optimizer:

int b;
void f ()
{
  int i = 0;
  if (b == 0)
    do {
      b = i;
      i++;
    } while (i < 10);
}

int main ()
{
  f ();
  if (b != 9)
    abort ();
  return 0;
}

If you look at the changes that were made on Jan 19 then this patch will
become obvious.


1999-05-13  Andreas Schwab  <schwab@issan.cs.uni-dortmund.de>

	* loop.c (check_dbra_loop): Fix change of Jan 19.

--- egcs-2.93/gcc/loop.c.~3~	Thu May 13 22:36:01 1999
+++ egcs-2.93/gcc/loop.c	Thu May 13 23:25:51 1999
@@ -7757,7 +7757,7 @@
 
 	      reversible_mem_store
 		= (! unknown_address_altered
-		   && ! invariant_p (XEXP (loop_store_mems, 0)));
+		   && ! invariant_p (XEXP (XEXP (loop_store_mems, 0), 0)));
 
 	      /* If the store depends on a register that is set after the
 		 store, it depends on the initial value, and is thus not

-- 
Andreas Schwab                                      "And now for something
schwab@issan.cs.uni-dortmund.de                      completely different"
schwab@gnu.org


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