For this bug, I am using the following test code:
#include <8051.h>
int main() {
unsigned char i;
i = 100;
do {
P1_1 = ~P1_1;
} while (--i);
return 0;
}
Using the latest CVS code for sdcc (Oct 24 2003), the
ASM code for the while condition is generated as:
;test.c:7: } while (--i);
; genMinus
; genMinusDec
mov a,r2
dec a
; genAssign
; genIfx
; Peephole 166 removed redundant mov
mov r3,a
mov ar2,r3
; genIfxJump
; Peephole 109 removed ljmp by inverse jump logic
jnz 00101$
It used to be much better! I happened to have an older
version of sdcc on another computer (Sep 26 2003) and
it produces this code:
;test.c:7: } while (--i);
; genDjnz
; Peephole 132 changed ljmp to sjmp
; Peephole 205 optimized misc jump sequence
djnz r2,00101$
So for some reason, SDCC no longer seems to find this
as an opportunity for "genDjnz".
Logged In: YES
user_id=635249
Broken by my fix for bug #818696, but should now be fixed
for both in src/SDCCicode.c 1.173