} by {
; Peephole 107 removed redundant ljmp
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
jc %1
; Peephole 115.b jump optimization
jz %3
%2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
replace {
clr a
mov a,%2
add a,#0xff - %1
mov %3,c
-}
+} if operandsLiteral(%1)
replace {
clr c
mov a,%2
add a,#0xff - %1
jnc %5
-}
+} if operandsLiteral(%1)
replace {
clr c
mov a,%2
add a,#0xff - %1
jc %5
-}
+} if operandsLiteral(%1)
replace {
clr c
mov a,#0x100 - %2
add a,%1
mov %3,c
-} if operandsNotRelated('0x00' %2)
+} if operandsNotRelated('0x00' %2), operandsLiteral(%2)
replace {
clr c
mov a,#0x100 - %2
add a,%1
jc %5
-} if operandsNotRelated('0x00' %2)
+} if operandsNotRelated('0x00' %2), operandsLiteral(%2)
replace {
clr c
mov a,#0x100 - %2
add a,%1
jnc %5
-} if operandsNotRelated('0x00' %2)
+} if operandsNotRelated('0x00' %2), operandsLiteral(%2)
replace {
mov r%1,a
}
+// applies to genlshOne
+replace {
+ mov ar%1,@%2
+ mov a,r%1
+ add a,acc
+ mov r%1,a
+} by {
+ ; Peephole 140 removed redundant mov
+ mov a,@%2
+ add a,@%2
+ mov r%1,a
+}
+
replace {
mov r%1,a
mov r%2,ar%1
; Peephole 160.a removed sjmp by inverse jump logic
jc %2
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
jc %1
; Peephole 160.b removed sjmp by inverse jump logic
jnc %2
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
jnz %1
; Peephole 160.c removed sjmp by inverse jump logic
jz %2
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
jz %1
; Peephole 160.d removed sjmp by inverse jump logic
jnz %2
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
jnb %3,%1
; Peephole 160.e removed sjmp by inverse jump logic
jb %3,%2
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
jb %3,%1
; Peephole 160.f removed sjmp by inverse jump logic
jnb %3,%2
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
mov %1,%2
; Peephole 168 jump optimization
jb %1,%3
%2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
replace {
jb %1,%2
; Peephole 169 jump optimization
jnb %1,%3
%2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
replace {
clr a
mov %1,a
} if notVolatile %1
-replace {
+// char indexed access to: long code table[] = {4,3,2,1};
+replace restart {
add a,#%1
mov dpl,a
clr a
mov %4,a
inc dptr
clr a
+ movc a,@a+dptr
} by {
; Peephole 186.a optimized movc sequence
+ mov b,a
mov dptr,#%1
- mov b,acc
movc a,@a+dptr
mov %2,a
- mov acc,b
inc dptr
+ mov a,b
movc a,@a+dptr
mov %3,a
- mov acc,b
inc dptr
+ mov a,b
movc a,@a+dptr
mov %4,a
- mov acc,b
inc dptr
+ mov a,b
+ movc a,@a+dptr
}
-replace {
+// char indexed access to: void* code table[] = {4,3,2,1};
+replace restart {
add a,#%1
mov dpl,a
clr a
mov %3,a
inc dptr
clr a
+ movc a,@a+dptr
} by {
; Peephole 186.b optimized movc sequence
+ mov b,a
mov dptr,#%1
- mov b,acc
movc a,@a+dptr
mov %2,a
- mov acc,b
inc dptr
+ mov a,b
movc a,@a+dptr
mov %3,a
- mov acc,b
inc dptr
+ mov a,b
+ movc a,@a+dptr
}
-replace {
+// char indexed access to: int code table[] = {4,3,2,1};
+replace restart {
add a,#%1
mov dpl,a
clr a
mov %2,a
inc dptr
clr a
+ movc a,@a+dptr
} by {
; Peephole 186.c optimized movc sequence
+ mov %2,a
mov dptr,#%1
- mov b,acc
movc a,@a+dptr
- mov %2,a
- mov acc,b
+ xch a,%2
inc dptr
+ movc a,@a+dptr
}
// char indexed access to: char code table[] = {4,3,2,1};
} by {
; Peephole 200.a removed redundant sjmp
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
sjmp %1
; Peephole 200.b removed redundant sjmp
%2:
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
push acc
mov %3,%4
%1:
ret
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
replace {
sjmp %1
mov dph,%6
%1:
ret
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
// applies to f.e. device/lib/log10f.c
replace {
inc a
%0:
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
// applies to generic pointer compare
replace {
inc a
%0:
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
// applies to f.e. time.c
replace {
inc a
%0:
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
// applies to f.e. malloc.c
replace {
inc a
%0:
%1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
// applies to f.e. j = (k!=0x1000);
// with volatile idata long k;
inc a
%1:
%2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
// applies to f.e. j = (p!=NULL);
// with volatile idata char *p;
inc a
%1:
%2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
// applies to f.e. j = (k!=0x1000);
// with volatile idata int k;
inc a
%1:
%2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
// applies to f.e. vprintf.asm (--stack-auto)
replace {
inc a
%1:
%2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
// applies to f.e. scott-bool1.c
replace {
} if notVolatile %1
-
-
// rules 247.x apply to f.e. bitfields.c
replace {
mov r%5,#%1
mov r%1,a
%4:
%3:
-} labelRefCountChange(%3 -1)
+} if labelRefCountChange(%3 -1)
// in_byte>>=1; if(in_bit) in_byte|=0x80;
replace {
mov r%1,a
%4:
%3:
-} labelRefCountChange(%3 -1)
+} if labelRefCountChange(%3 -1)
// out_bit=out_byte&0x80; out_byte<<=1;
// helps f.e. writing data on a 3-wire (SPI) bus
mov %1,#(%2 + 1)
}
+
+replace {
+ clr a
+ cjne %1,%2,%3
+ inc a
+%3:
+ jz %4
+} by {
+ ; Peephole 264 jump optimization (acc not set)
+ cjne %1,%2,%4
+%3:
+} if labelRefCount(%3 1), labelRefCountChange(%3 -1)
+
// should be one of the last peepholes
replace{
%1: