#141 sdcc optimization

open
nobody
None
5
2006-05-24
2006-05-24
Anonymous
No

SDCC regularily reinserts the same value into registers
- most noteably, the xdata dptr registers:

Is it possible to keep currentl values for each
register to determine whether there is a need to set
the register or leave it alone?

eg:

{
xdata lock;

if (--lock)
mybit = 0;
}

-------
986 ; genMinus
0073 90 07 F0 987 mov dptr,#_lock
988 ; genMinusDec
0076 E0 989 movx a,@dptr
0077 14 990 dec a
991 ; genAssign
0078 90 07 F0 992 mov dptr,#_lock
007B F0 993 movx @dptr,a
994 ; genAssign
007C 90 07 F0 995 mov dptr,#_lock
007F E0 996 movx a,@dptr
997 ; genIfx
998 ; Peephole 105
removed redundant mov
0080 FD 999 mov r5,a
1000 ; genIfxJump
1001 ; Peephole 109
removed ljmp by inverse jump logic
0081 70 02 1002 jnz 00102$
0083 1003 00127$:
1004 ; genAssign
0083 D2 CD 1005 setb _mybit
----

There are a number of other places where sdcc could do
much better as well:

moving data into registers which are then not used. etc.

Is it possible to extend the peephole syntax to allow
specifying that n unrelated instructions can occur
between the sequence in question?

ie say to optimize:

push ar2
push ar3
mov r5, a
pop ar3
pop ar2

say: (a better syntax could be found I'm sure)
replace restart {
pop %1
x = *(mov, add, dec) ! %1
push %1
} by {
; nop - peepfile
x
}

where the wildcard format is:

<x> = [*](inst1, inst2, !inst3, [*]) ! %[arg1],
%[arg2], ... %[argn]

match sequence <x> where:
[*] - any of: (if no star .. must be all of)
(inst1, ..) instruction list.
!instx - exclude instruction (eg lcall)
* - match any instruction.
- if followed by a !inst4, then remove inst4
from list of all instructions.

! %[arg1], %[arg2] - where arg1, arg2, ... was
unreferenced

--
Carl van Schaik

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks