gnupic@linuxhacker.org

gnupic@linuxhacker.org


Subject: Re: SDCC overoptimizing
From: Scott Dattalo
Date: Sun, 30 Mar 2003 16:36:51 -0800 (PST)

On Sat, 29 Mar 2003, Erik Gustavsson wrote:

> > > 
> > > ;  PORTB=(PORTB&0xf0)|(0x02);
> > >         MOVLW   0xf0
> > >         ANDWF   _PORTB,W
> > >         MOVLW   0x02
> > >         MOVWF   _PORTB
> > > 
> > > Seems to me the second MOVLW should have been a IORLW.
> > > I was kind of thinking of having a look at the SDCC 
> > > code myself, but I don't really know where to start...
> > 
> > Yep, that's a bug.
> > 
> 
> Here's a patch: 
> http://area26.no-ip.org/download/misc/sdcc-orfix.patch

Erik,

I saw your message, but forgot about it when I was fixing the bug... But, 
your patch looks good (although I didn't use it.) In addition to the OR 
and AND bugs, the problem exists with XOR and NEG. I fixed all of these, 
but I wouldn't be surprised to see variations that still caused problems. 
See 

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/sdcc/sdcc/src/regression/and2.c

for the cases that are tested.

Scott



gnupic@linuxhacker.org