🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #124

`gcc' optimizes the enclosed program incorrectly

#124
From: Derek Clegg
Date: Fri, 23 Jun 1989 19:24
60 lines
1696 bytes
/* Version:
 *     gcc version 1.35
 * File:
 *     <this file>
 * Compile with:
 *     gcc -O -S <this file>
 * Problem:
 *     `gcc' optimizes the following program incorrectly.
 * Notes:
 *     gcc was compiled with `config.gcc sun3-os4'.
 *     I am using a Sun 3/60 with UNIX 4.2 (Sun release 4.0.1).
 *
 *		Derek B Clegg ({uunet,ucbcad,sun}!island!derek)
 */

void
matte(dst, w, color, alpha)
unsigned char *dst;
int w, color;
unsigned char *alpha;
{
    int v;

    while (--w >= 0) {
	v = *dst;
	*dst++ = v + ((color - v)*(*alpha++) >> 8);
    }

#if 0
/*
 * In the line marked with `%' below, we see that `v' (originally containing
 * `*dst') is overwritten with the value `*alpha'.  This is incorrect, since
 * `v' is subsequently used.
 */
_matte:
	link a6,#0
	moveml #0x3000,sp@-
	movel a6@(8),a0		| dst
	movel a6@(12),d2	| w
	movel a6@(16),d3	| color
	movel a6@(20),a1	| alpha
	clrl d1			| v
	jra L2
L4:
	moveb a0@,d1		| v = *dst 
	movel d3,d0		| tmp = color
	subl d1,d0		| tmp -= v
%	moveb a1@+,d1		| v = *alpha++ (!)
	mulsl d1,d0		| tmp *= v
	asrl #8,d0		| tmp >>= 8
	addb d1,d0		| tmp += v (= *alpha)
	moveb d0,a0@+		| *dst++ = tmp
L2:
	subql #1,d2		| --w
	jpl L4
	moveml a6@(-8),#0xc
	unlk a6
	rts
#endif
}
Technical Details
Message-ID: <8906231924.AA07302@orkney.island.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!island!orkney!derek

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!island!orkney!derek
From: island!orkney!derek@UUNET.UU.NET (Derek Clegg)
Newsgroups: gnu.gcc.bug
Subject: `gcc' optimizes the enclosed program incorrectly
Message-ID: <8906231924.AA07302@orkney.island.uucp>
Date: 23 Jun 89 19:24:01 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 60