Subject: Re: gcc 2.7.2.1 bug
To: Ale Terlevich <A.I.Terlevich@durham.ac.uk>
From: Richard Earnshaw <rearnsha@armltd.co.uk>
List: port-arm32
Date: 11/20/1996 20:42:57
A.I.Terlevich@durham.ac.uk said:
>   Whilst trying to compile xtank, I came accross some code which 
> makes gcc a tad upset.

> ...

> garp:~> gcc -c -O junk.c junk.c: In function `MyVehicleIsClosest': 
> junk.c:47: internal error--insn does not satisfy its constraints: 
> (insn:HI 32 170 173 (set (reg/v:SI 2 r2)
>	  (plus:SI (mult:SI (reg/v:SI 2 r2)
>		  (reg/v:SI 2 r2))
>	      (reg:SI 3 r3))) 36 {mulsi3+3} (insn_list 20 (insn_list 30 (nil)))
>       (expr_list:REG_DEAD (reg/v:SI 2 r2) 
>	    (expr_list:REG_DEAD (reg:SI 3 r3)
>	        (nil))))
> gcc: Internal compiler error: program cc1 got fatal signal 6

Hmm, seems I was trying to be too clever for register allocator.  This
patch should fix this problem for now while I think about the problem further.

>   I thought I'd include the source with this mail as it's short, and I 
> don't know who else to send it to!

Bugs in gcc should really be sent to bug-gcc@prep.ai.mit.edu along with
a sample as you have done.  See the documentation on gcc for what you
should send.

Richard.

*** reload.c.keep	Sat Nov 11 13:23:54 1995
--- reload.c	Wed Nov 20 20:21:25 1996
*************** find_reloads (insn, replace, ind_levels,
*** 3216,3221 ****
--- 3216,3240 ----
  		    }
  	      }
  	  }
+         /* the alternative has an early clobber, and will need a reload.  */
+ 	else if (this_alternative_earlyclobber[i])
+ 	{
+ 	  for (j = 0; j < noperands; j++)
+ 	    /* The following implies that this particular operand will not
+ 	       be clobbered */
+ 	    if (this_alternative_matches[j] == i)
+ 	    {
+ 	      /* However, we must ensure that no other operand that could
+ 		 be clobbered is that same as that, since that cannot
+ 		 be handled.  */
+ 	      int k;
+ 
+ 	      for (k = 0; k < noperands; k++)
+ 		if (k != i && k != j
+ 		    && recog_operand[j] == recog_operand[k])
+ 		  bad = 1;
+ 	    }
+ 	}
  
        /* If one alternative accepts all the operands, no reload required,
  	 choose that alternative; don't consider the remaining ones.  */