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]

checked in patch for infinite loop in cse.c:find_comparison_args


I've checked in a patch to avoid infinite loops in cse.c:find_comparison_args.

The compiler would look at a register that it knew was equal to a constant,
and therefore equivalent to a comparison of another register used later in
the insn stream, and that register in turn was constant too and eqivalent
to a comparison of the first register.

Approved by Richard Henderson.

Bootstrapped on i686-pc-linux-gnu.

Fri Jan  5 20:34:06 2001  J"orn Rennecke <amylaar@redhat.com>

	* cse.c (find_comparison_args): Stop if the argument is known to
	be constant.

Index: cse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cse.c,v
retrieving revision 1.169
diff -p -r1.169 cse.c
*** cse.c	2001/01/03 14:29:01	1.169
--- cse.c	2001/01/05 20:33:59
*************** find_comparison_args (code, parg1, parg2
*** 3161,3167 ****
  	p = lookup (arg1, safe_hash (arg1, GET_MODE (arg1)) & HASH_MASK,
  		    GET_MODE (arg1));
        if (p)
! 	p = p->first_same_value;
  
        for (; p; p = p->next_same_value)
  	{
--- 3161,3180 ----
  	p = lookup (arg1, safe_hash (arg1, GET_MODE (arg1)) & HASH_MASK,
  		    GET_MODE (arg1));
        if (p)
! 	{
! 	  p = p->first_same_value;
! 
! 	  /* If what we compare is already known to be constant, that is as
! 	     good as it gets.
! 	     We need to break the loop in this case, because otherwise we
! 	     can have an infinite loop when looking at a reg that is known
! 	     to be a constant which is the same as a comparison of a reg
! 	     against zero which appears later in the insn stream, which in
! 	     turn is constant and the same as the comparison of the first reg
! 	     against zero...  */
! 	  if (p->is_const)
! 	    break;
! 	}
  
        for (; p; p = p->next_same_value)
  	{

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