derek@UUNET.UU.NET (Derek Clegg) (06/24/89)
/* 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
}