Subject: 'c2' improvement and a fix
Index:	lib/c2/c21.c 2.11BSD

Description:
	There is a small bug in the optimizing of 'tst' instructions.  The
	BYTE nature of the previous instruction is being ignored.  This
	could lead to (but has not been observed):  

			inc	_a
			tstb	_a
			jeq	...

	being incorrectly optimized to:

			inc	_a
			jeq	...

	The fix to the above is to make sure the BYTE suffix on the 'tst'
	instruction matches that of the preceeding instruction.

	A chance for an additional optimization was observed recently
	in the kernel:

		u.u_error = somefunction();  [or u.u_error = ERRNO;]
		if (u.u_error)
			dosomething();

	would generate something like:

		movb	r0, u+0240
		tstb	u+0240
		jeq	...

	instead of:
		
		movb	r0,u+0240
		jeq	...

	A savings of an instruction and 4 bytes for each 'tst' removed.  This
	sequence occurs fairly frequently in the kernel.

Repeat-By:
	c2 can be run interactively, so on a terminal type:

	/lib/c2
	movb r0,a
	tstb a
	inc a
	tstb a
	^D

	and receive as output on the terminal:

	movb r0,a
	tstb a
	inc a

	instead of:

	movb r0,a
	inc a
	tstb a

Fix:
	Apply the patch below, recompile and install /lib/c2
-------------------------------------------------------------------------------
*** /usr/src/lib/c2/c21.c.old	Sat Nov  2 16:42:32 1991
--- /usr/src/lib/c2/c21.c	Sun Dec 29 19:02:02 1991
***************
*** 207,213 ****
  		singop(p);
  		repladdr(p, 0, flt);
  		source(regs[RT1]);
! 		if (equstr(regs[RT1], ccloc)) {
  			p->back->forw = p->forw;
  			p->forw->back = p->back;
  			p = p->back;
--- 207,218 ----
  		singop(p);
  		repladdr(p, 0, flt);
  		source(regs[RT1]);
! 		if (p->back->op == MOV && p->back->subop == BYTE) {
! 			dualop(p->back);
! 			setcc(regs[RT2]);
! 			singop(p);
! 		}
! 		if (equstr(regs[RT1], ccloc) && p->subop == p->back->subop) {
  			p->back->forw = p->forw;
  			p->forw->back = p->back;
  			p = p->back;
