[5614] in Athena Bugs

home help back first fref pref prev next nref lref last post

hc 2.1y optimizer bug

daemon@ATHENA.MIT.EDU (John Carr)
Fri Jul 27 09:40:23 1990

To: bugs@ATHENA.MIT.EDU
Date: Fri, 27 Jul 90 09:40:12 EDT
From: John Carr <jfc@ATHENA.MIT.EDU>


This function

	unsigned int f(unsigned int *x)
	{
	  while((*x++)--);
	  return *x;
	}

compiles to this code:

	_.f:
		ls	r0,0(r2)
	L00012:
		cis	r0,0
		inc	r2,4
		dec	r0,1
		sts	r0,0(r2)
		jne	L00012
		mr	r0,r0	# no op to fix APC bug
		mr	r0,r0	# no op to fix APC bug
		mr	r0,r0	# no op to fix APC bug
		brx	r15
		mr	r2,r0
		.long	0xdf02df00	#Trace table (no stack frame)


The "ls r0,0(r2)" needs to be within the loop; as compiled the loop is
equivalent to:

	int y = *x;
	while(*x++ = y--);


[a new version of hc2.1 is due out in a bit over a month; this should
be sent to IBM quickly if it is to affect the new version]


home help back first fref pref prev next nref lref last post