disabled 186.d as temporary fix for #1434401
[fw/sdcc] / src / mcs51 / peeph.def
index 779300776f08b72477e860e221eff26109f4e7e0..30ddc1307f64e5d0e03b686f8e9f9a79b1de8538 100644 (file)
@@ -44,7 +44,7 @@ replace {
        mov     %1,a
 }
 
-replace {
+replace restart {
 // saving 1 byte, loosing 1 cycle but maybe allowing peephole 3.b to start
        mov     %1,#0x00
        mov     %2,#0x00
@@ -286,7 +286,7 @@ replace {
 } by {
        ;       Peephole 107    removed redundant ljmp
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        jc      %1
@@ -402,7 +402,7 @@ replace {
        ;       Peephole 115.b  jump optimization
        jz      %3
 %2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
 
 replace {
        clr     a
@@ -1063,7 +1063,7 @@ replace {
        ;       Peephole 160.a  removed sjmp by inverse jump logic
        jc      %2
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        jc      %1
@@ -1073,7 +1073,7 @@ replace {
        ;       Peephole 160.b  removed sjmp by inverse jump logic
        jnc     %2
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        jnz     %1
@@ -1083,7 +1083,7 @@ replace {
        ;       Peephole 160.c  removed sjmp by inverse jump logic
        jz      %2
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        jz      %1
@@ -1093,7 +1093,7 @@ replace {
        ;       Peephole 160.d  removed sjmp by inverse jump logic
        jnz     %2
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        jnb     %3,%1
@@ -1103,7 +1103,7 @@ replace {
        ;       Peephole 160.e  removed sjmp by inverse jump logic
        jb      %3,%2
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        jb      %3,%1
@@ -1113,7 +1113,7 @@ replace {
        ;       Peephole 160.f  removed sjmp by inverse jump logic
        jnb     %3,%2
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        mov     %1,%2
@@ -1142,7 +1142,7 @@ replace {
        ;       Peephole 168    jump optimization
        jb      %1,%3
 %2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
 
 replace {
        jb      %1,%2
@@ -1152,7 +1152,7 @@ replace {
        ;       Peephole 169    jump optimization
        jnb     %1,%3
 %2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
 
 replace {
        clr     a
@@ -1536,20 +1536,21 @@ replace {
        inc     dptr
 }
 
-// char indexed access to: char code table[] = {4,3,2,1};
-replace {
-       add     a,#%1
-       mov     dpl,a
-       clr     a
-       addc    a,#(%1 >> 8)
-       mov     dph,a
-       clr     a
-       movc    a,@a+dptr
-} by {
-       ;       Peephole 186.d  optimized movc sequence
-       mov     dptr,#%1
-       movc    a,@a+dptr
-}
+// disabled due to bug #1434401
+//// char indexed access to: char code table[] = {4,3,2,1};
+//replace {
+//     add     a,#%1
+//     mov     dpl,a
+//     clr     a
+//     addc    a,#(%1 >> 8)
+//     mov     dph,a
+//     clr     a
+//     movc    a,@a+dptr
+//} by {
+//     ;       Peephole 186.d  optimized movc sequence
+//     mov     dptr,#%1
+//     movc    a,@a+dptr
+//}
 
 // char indexed access to: int code table[] = {4,3,2,1};
 replace {
@@ -1893,7 +1894,7 @@ replace {
 } by {
        ;       Peephole 200.a  removed redundant sjmp
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        sjmp    %1
@@ -1903,7 +1904,7 @@ replace {
        ;       Peephole 200.b  removed redundant sjmp
 %2:
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        push    acc
@@ -2211,6 +2212,18 @@ replace {
        ;       Peephole 225    removed redundant move to acc
 } if notVolatile %1
 
+replace {
+       clr     a
+       movx    @%1,a
+       inc     %1
+       clr     a
+} by {
+       clr     a
+       movx    @%1,a
+       inc     %1
+       ;       Peephole 226.a  removed unnecessary clr
+}
+
 replace {
        clr     a
        movx    @%1,a
@@ -2224,7 +2237,7 @@ replace {
        inc     %1
        movx    @%1,a
        inc     %1
-       ;       Peephole 226    removed unnecessary clr
+       ;       Peephole 226.b  removed unnecessary clr
 }
 
 replace {
@@ -2482,7 +2495,7 @@ replace {
        mov     %3,%4
 %1:
        ret
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 replace {
        sjmp    %1
@@ -2501,7 +2514,7 @@ replace {
        mov     dph,%6
 %1:
        ret
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 // applies to f.e. device/lib/log10f.c
 replace {
@@ -2623,7 +2636,7 @@ replace {
        inc     a
 %0:
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 // applies to generic pointer compare
 replace {
@@ -2644,7 +2657,7 @@ replace {
        inc     a
 %0:
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 // applies to f.e. time.c
 replace {
@@ -2663,7 +2676,7 @@ replace {
        inc     a
 %0:
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 // applies to f.e. malloc.c
 replace {
@@ -2680,7 +2693,7 @@ replace {
        inc     a
 %0:
 %1:
-} labelRefCountChange(%1 -1)
+} if labelRefCountChange(%1 -1)
 
 // applies to f.e. j = (k!=0x1000);
 // with volatile idata long k;
@@ -2710,7 +2723,7 @@ replace {
        inc     a
 %1:
 %2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
 
 // applies to f.e. j = (p!=NULL);
 // with volatile idata char *p;
@@ -2736,7 +2749,7 @@ replace {
        inc     a
 %1:
 %2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
 
 // applies to f.e. j = (k!=0x1000);
 // with volatile idata int k;
@@ -2758,7 +2771,7 @@ replace {
        inc     a
 %1:
 %2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
 
 // applies to f.e. vprintf.asm (--stack-auto)
 replace {
@@ -2775,7 +2788,7 @@ replace {
        inc     a
 %1:
 %2:
-} labelRefCountChange(%2 -1)
+} if labelRefCountChange(%2 -1)
 
 // applies to f.e. scott-bool1.c
 replace {
@@ -3846,7 +3859,7 @@ replace {
        mov     r%1,a
 %4:
 %3:
-} labelRefCountChange(%3 -1)
+} if labelRefCountChange(%3 -1)
 
 // in_byte>>=1; if(in_bit) in_byte|=0x80;
 replace {
@@ -3886,7 +3899,7 @@ 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
@@ -4475,6 +4488,33 @@ replace {
        ;       Peephole 262    removed redundant cpl c
 }
 
+replace {
+       mov     %1,#%2
+       inc     %1
+       inc     %1
+       inc     %1
+} by {
+       ;       Peephole 263.a  optimized loading const
+       mov     %1,#(%2 + 3)
+}
+
+replace {
+       mov     %1,#%2
+       inc     %1
+       inc     %1
+} by {
+       ;       Peephole 263.b  optimized loading const
+       mov     %1,#(%2 + 2)
+}
+
+replace {
+       mov     %1,#%2
+       inc     %1
+} by {
+       ;       Peephole 263.c  optimized loading const
+       mov     %1,#(%2 + 1)
+}
+
 // should be one of the last peepholes
 replace{
 %1: