On Wed, 18 Aug 2004, Phuah Yee Keat wrote:
> > I think the patch does what you intend, but I'm not entirely convinced
> > that the change in generated code is always better. At the very least, I
> > think it should be limited to 8-bit operands, since literal assignment is
> > always faster than increment/decrement for 16-bit and 32-bit operands on
> > the 8-bit targets that SDCC currently supports.
> Yeap, that hits me as well. But the mcs51 port does have a "inc dptr"
> opcode which increases a 16 bit operand.
That only helps if the operand happened to be in dptr, otherwise time will
be wasted getting the value into and out of dptr. Most of the backend code
generators support a post increment on pointer operation optimization, so
retaining the increment in that situation might be worthwhile. However, in
the sample code posted in RFE #966755 "only use direct assignment if it's
faster", if the tmp variable is changed from a char to an int, we get:
(without patch: optimize to direct assignment)
(with patch: explicit decrement)
In this case, the direct assignment is faster.
> On the other hand, I am also not sure whether all the ports have a
> "dec/inc" opcode. I just did a ramdom check on the pic/ port, seems that
> the line for doing genMinusDec is commented out.
> Erik, mine explaining why my patch failed to z80 port, is that a bug in
> the z80 port? I have attempted to troubleshoot the problem, but given my
> zero-knowledge on the z80, failed terribly.
Yes, it was a bug in the z80 port. Like the other ports, its register
allocator attempts to simplify the assignments created by the iCode
generator so that fewer registers will be needed. The problem was that it
failed to distinguish between assignment to a pointer itself and indirect
assignment through a pointer. Although there were several changes in my
commit, the fix for this bug was the addition of
if (POINTER_SET (dic))
dic = NULL;
> > Please don't feel that your patches are being rejected; I am just trying
> > to understand the full consequences of the changes before applying them.
> Don't worry. I just want to improve on the stuffs so you guys would not
> need to do much (like add comments) etc...
I just didn't want you to become discouraged. A patch locates a possible
problem and offers a solution. Locating a problem is often the harder
part, so I am grateful for any input.