5 // ; Peephole 1 removed pop %1 push %1 (not push pop)
13 // ; Peephole 2 removed pop %1 push %1 (not push pop)
18 // added by Jean Louis VERN for
24 ; Peephole 2.a removed redundant xch xch
32 ; Peephole 3.a changed mov to clr
42 ; Peephole 3.b changed mov to clr
48 // saving 1 byte, loosing 1 cycle but maybe allowing peephole 3.b to start
53 ; Peephole 3.c changed mov to clr
66 ; Peephole 100 removed redundant mov
74 ; Peephole 100.a removed redundant mov
84 ; Peephole 101 removed redundant mov
102 ; Peephole 102 removed redundant mov
124 ; Peephole 103 removed redundant mov
141 ; Peephole 104 optimized increment (acc not set to r%1, flags undefined)
150 ; Peephole 105 removed redundant mov
159 ; Peephole 106 removed redundant mov
168 ; Peephole 107 removed redundant ljmp
177 ; Peephole 108 removed ljmp by inverse jump logic
187 ; Peephole 109 removed ljmp by inverse jump logic
197 ; Peephole 110 removed ljmp by inverse jump logic
207 ; Peephole 111 removed ljmp by inverse jump logic
217 ; Peephole 112 removed ljmp by inverse jump logic
226 ; Peephole 132 changed ljmp to sjmp
240 ; Peephole 113 optimized misc sequence
245 } if labelRefCount %3 1
256 ; Peephole 114 optimized misc sequence
262 } if labelRefCount %3 2
271 ; Peephole 115 jump optimization
275 } if labelRefCount %3 1
285 ; Peephole 116 jump optimization
290 } if labelRefCount %3 2
301 ; Peephole 117 jump optimization
307 } if labelRefCount %3 3
319 ; Peephole 118 jump optimization
326 } if labelRefCount %3 4
335 ; Peephole 119 jump optimization
338 } if labelRefCount %3 1
348 ; Peephole 120 jump optimization
352 } if labelRefCount %3 2
363 ; Peephole 121 jump optimization
368 } if labelRefCount %3 3
380 ; Peephole 122 jump optimization
386 } if labelRefCount %3 4
395 ; Peephole 123 jump optimization
399 } if labelRefCount %3 1
409 ; Peephole 124 jump optimization
414 } if labelRefCount %3 2
425 ; Peephole 125 jump optimization
431 } if labelRefCount %3 3
443 ; Peephole 126 jump optimization
450 } if labelRefCount %3 4
463 ; Peephole 127 removed misc sequence
465 } if labelRefCount %3 0
472 ; Peephole 128 jump optimization
481 ; Peephole 129 jump optimization
488 ; Peephole 130 changed target address mode r%1 to ar%1
498 ; Peephole 131 optimized decrement (not caring for c)
510 ; Peephole 133 removed redundant moves
523 ; Peephole 134 removed redundant moves
534 ; Peephole 135 removed redundant mov
545 ; Peephole 136 removed redundant moves
551 // WTF? Doesn't look sensible to me...
561 // ; Peephole 137 optimized misc jump sequence
565 //} if labelRefCount %4 1
576 // ; Peephole 138 optimized misc jump sequence
581 //} if labelRefCount %4 1
588 ; Peephole 139 removed redundant mov
598 ; Peephole 140 removed redundant mov
607 ; Peephole 141 removed redundant mov
617 ; Peephole 142 removed redundant moves
626 ; Peephole 143 converted rlc to rl
634 ; Peephole 144 converted rrc to rc
642 ; Peephole 145 changed to add without carry
651 ; Peephole 146 changed to add without carry
659 ; Peephole 147 changed target address mode r%1 to ar%1
666 ; Peephole 148 changed target address mode r%1 to ar%1
673 ; Peephole 149 changed target address mode r%1 to ar%1
683 ; Peephole 150 removed misc moves via dpl before return
696 ; Peephole 151 removed misc moves via dph, dpl before return
708 ; Peephole 152 removed misc moves via dph, dpl before return
723 ; Peephole 153 removed misc moves via dph, dpl, b before return
736 ; Peephole 154 removed misc moves via dph, dpl, b before return
750 ; Peephole 155 removed misc moves via dph, dpl, b before return
767 ; Peephole 156 removed misc moves via dph, dpl, b, a before return
782 ; Peephole 157 removed misc moves via dph, dpl, b, a before return
796 ; Peephole 158 removed misc moves via dph, dpl, b, a before return
805 ; Peephole 159 avoided xrl during execution
814 ; Peephole 160 removed sjmp by inverse jump logic
824 ; Peephole 161 removed sjmp by inverse jump logic
834 ; Peephole 162 removed sjmp by inverse jump logic
844 ; Peephole 163 removed sjmp by inverse jump logic
854 ; Peephole 164 removed sjmp by inverse jump logic
864 ; Peephole 165 removed sjmp by inverse jump logic
874 ; Peephole 166 removed redundant mov
884 ; Peephole 167 removed redundant bit moves (c not set to %1)
893 ; Peephole 168 jump optimization
903 ; Peephole 169 jump optimization
915 ; Peephole 170 jump optimization
918 } if labelRefCount %3 1
928 ; Peephole 171 jump optimization
932 } if labelRefCount %3 2
943 ; Peephole 172 jump optimization
948 } if labelRefCount %3 3
960 ; Peephole 173 jump optimization
966 } if labelRefCount %3 4
975 ; Peephole 174 optimized decrement (acc not set to %2, flags undefined)
986 ; Peephole 175 optimized increment (acc not set to %2, flags undefined)
996 ; Peephole 176 optimized increment, removed redundant mov
1001 // this one will screw assignes to volatile/sfr's
1006 // ; Peephole 177 removed redundant mov
1010 // applies to f.e. scott-add.asm (--model-large)
1015 ; Peephole 177 removed redundant mov
1024 ; Peephole 178 removed redundant mov
1029 // rules 179-182 provided by : Frieder <fe@lake.iup.uni-heidelberg.de>
1030 // saving 2 byte, 1 cycle
1035 ; Peephole 179 changed mov to clr
1040 // saving 1 byte, 0 cycles
1044 ; Peephole 180 changed mov to clr
1048 // saving 3 bytes, 2 cycles
1049 // provided by Bernhard Held <bernhard.held@de.westinghouse.com>
1054 ; Peephole 182.a used 16 bit load of DPTR
1058 // saving 3 byte, 2 cycles, return(NULL) profits here
1063 ; Peephole 182.b used 16 bit load of dptr
1067 // saving 3 byte, 2 cycles. Probably obsoleted by 182.b
1072 ; Peephole 182.c used 16 bit load of dptr
1073 mov dptr,#(((%2)<<8) + %1)
1080 ; Peephole 183 avoided anl during execution
1089 ; Peephole 184 removed redundant mov
1095 // acc being incremented might cause problems
1099 ; Peephole 185 changed order of increment (acc incremented also!)
1124 ; Peephole 186.a optimized movc sequence
1156 ; Peephole 186.b optimized movc sequence
1181 ; Peephole 186.c optimized movc sequence
1199 ; Peephole 186.d optimized movc sequence
1209 ; Peephole 187 used a instead of ar%1 for anl
1221 ; Peephole 188 removed redundant mov
1233 ; Peephole 189 removed redundant mov and anl
1238 // rules 190 & 191 need to be in order
1244 ; Peephole 190 removed redundant mov
1256 ; Peephole 191 removed redundant mov
1267 ; Peephole 192 used a instead of ar%1 as source
1284 ; Peephole 193.a optimized misc jump sequence
1294 } if labelRefCount %3 4
1308 ; Peephole 193.b optimized misc jump sequence
1318 } if labelRefCount %3 4
1332 ; Peephole 193.c optimized misc jump sequence
1342 } if labelRefCount %3 4
1353 ; Peephole 194 optimized misc jump sequence
1360 } if labelRefCount %3 4
1372 ; Peephole 195.a optimized misc jump sequence
1380 } if labelRefCount %3 3
1392 ; Peephole 195.b optimized misc jump sequence
1400 } if labelRefCount %3 3
1412 ; Peephole 195.c optimized misc jump sequence
1420 } if labelRefCount %3 3
1430 ; Peephole 196 optimized misc jump sequence
1436 } if labelRefCount %3 3
1446 ; Peephole 197.a optimized misc jump sequence
1452 } if labelRefCount %3 2
1462 ; Peephole 197.b optimized misc jump sequence
1468 } if labelRefCount %3 2
1478 ; Peephole 197.c optimized misc jump sequence
1484 } if labelRefCount %3 2
1493 ; Peephole 198 optimized misc jump sequence
1498 } if labelRefCount %3 2
1506 ; Peephole 199 optimized misc jump sequence
1510 } if labelRefCount %3 1
1516 ; Peephole 200 removed redundant sjmp
1525 ; Peephole 201 removed redundant sjmp
1535 ; Peephole 202 removed redundant push pop
1544 ; Peephole 203 removed mov r%1,_spx
1553 ; Peephole 204 removed redundant mov
1565 ; Peephole 205 optimized misc jump sequence
1569 } if labelRefCount %2 1
1574 ; Peephole 206 removed redundant mov %1,%1
1582 ; Peephole 207 removed zero add (acc not set to %1, flags undefined)
1591 ; Peephole 208 removed redundant push pop
1601 ; Peephole 209 optimized increment (acc not set to %1, flags undefined)
1607 mov dptr,#((((%1 >> 8)) <<8) + %1)
1609 ; Peephole 210 simplified expression
1617 ; Peephole 211 removed redundant push %1 pop %1
1625 ; Peephole 212 reduced add sequence to inc
1631 mov %1,#(( %2 >> 8 ) ^ 0x80)
1633 ; Peephole 213.a inserted fix
1639 mov %1,#(( %2 + %3 >> 8 ) ^ 0x80)
1641 ; Peephole 213.b inserted fix
1642 mov %1,#((%2 + %3) >> 8)
1651 ; Peephole 214 reduced some extra moves
1654 } if operandsNotSame
1661 ; Peephole 215 removed some moves
1664 } if operandsNotSame
1674 ; Peephole 216 simplified clear (2bytes)
1693 ; Peephole 217 simplified clear (3bytes)
1717 ; Peephole 218 simplified clear (4bytes)
1736 ; Peephole 219 removed redundant clear
1752 ; Peephole 219.a removed redundant clear
1765 ; Peephole 220.a removed bogus DPS set
1773 ; Peephole 220.b removed bogus DPS set
1778 mov %1 + %2,(%2 + %1)
1780 ; Peephole 221.a remove redundant move
1784 mov (%1 + %2 + %3),((%2 + %1) + %3)
1786 ; Peephole 221.b remove redundant move
1793 ; Peephole 222 removed dec/inc pair
1802 ; Peephole 223 removed redundant dph/dpl moves
1813 ; Peephole 224 removed redundant dph/dpl moves
1826 ; Peephole 225 removed redundant move to acc
1842 ; Peephole 226 removed unnecessary clr
1864 ; Peephole 227 replaced inefficient 32 bit clear
1892 ; Peephole 228 replaced inefficient 32 constant
1914 ; Peephole 229 replaced inefficient 16 bit clear
1932 ; Peephole 230 replaced inefficient 16 constant
1942 // this last peephole often removes the last mov from 227-230
1947 ; Peephole 231 removed redundant mov to dptr
1954 ; Peephole 232 using movc to read xdata (--xram-movc)
1962 ; Peephole 233 using _gptrgetc instead of _gptrget (--xram-movc)
1972 ; Peephole 234 loading dpl directly from a(ccumulator), r%1 not set
1985 ; Peephole 235 loading dph directly from a(ccumulator), r%1 not set
1992 // 14 rules by Fiorenzo D. Ramaglia <fd.ramaglia@tin.it>
1997 ; Peephole 236.a used r%1 instead of ar%1
2004 ; Peephole 236.b used r%1 instead of ar%1
2011 ; Peephole 236.c used r%1 instead of ar%1
2018 ; Peephole 236.d used r%1 instead of ar%1
2025 ; Peephole 236.e used r%1 instead of ar%1
2032 ; Peephole 236.f used r%1 instead of ar%1
2039 ; Peephole 236.g used r%1 instead of ar%1
2046 ; Peephole 236.h used r%1 instead of ar%1
2053 ; Peephole 236.i used r%1 instead of ar%1
2060 ; Peephole 236.j used r%1 instead of ar%1
2067 ; Peephole 236.k used r%1 instead of ar%1
2074 ; Peephole 236.l used r%1 instead of ar%1
2081 ; Peephole 236.m used r%1 instead of ar%1
2088 ; Peephole 236.n used r%1 instead of ar%1
2099 ; Peephole 237.a removed sjmp to ret
2116 ; Peephole 237.b removed sjmp to ret
2126 // applies to f.e. device/lib/log10f.c
2152 ; Peephole 238.a removed 4 redundant moves
2153 } if operandsNotSame8 %1 %2 %3 %4 %5 %6 %7 %8
2155 // applies to device/lib/log10f.c
2170 ; Peephole 238.b removed 3 redundant moves
2171 } if operandsNotSame7 %1 %2 %3 %4 %5 %6 %7
2173 // applies to f.e. device/lib/time.c
2189 ; Peephole 238.c removed 2 redundant moves
2190 } if operandsNotSame4 %1 %2 %3 %4
2192 // applies to f.e. support/regression/tests/bug-524209.c
2205 ; Peephole 238.d removed 3 redundant moves
2206 } if operandsNotSame6 %1 %2 %3 %4 %5 %6
2208 // applies to f.e. ser_ir.asm
2212 ; Peephole 239 used a instead of acc
2220 ; Peephole 240 use clr instead of addc a,#0
2225 // peepholes 241.a to 241.c and 241.d to 241.f need to be in order
2237 ; Peephole 241.a optimized compare
2248 // applies to f.e. time.c
2258 ; Peephole 241.b optimized compare
2267 // applies to f.e. malloc.c
2276 ; Peephole 241.c optimized compare
2284 // applies to f.e. j = (k!=0x1000);
2285 // with volatile idata long k;
2300 ; Peephole 241.d optimized compare
2314 // applies to f.e. j = (k!=0x1000);
2315 // with volatile idata int k;
2326 ; Peephole 241.e optimized compare
2336 // applies to f.e. vprintf.asm (--stack-auto)
2345 ; Peephole 241.f optimized compare
2353 // applies to f.e. scott-bool1.c
2360 ; Peephole 242.a avoided branch jnz to jz
2365 } if labelRefCount %1 1
2367 // applies to f.e. scott-bool1.c
2375 ; Peephole 242.b avoided branch jnz to jz
2381 } if labelRefCount %1 1
2383 // applies to f.e. logic.c
2393 ; Peephole 242.c avoided branch jnz to jz
2401 } if labelRefCount %1 1
2403 // applies to f.e. vprintf.c
2404 // this is a rare case, usually the "tail increment" is noticed earlier
2411 ; Peephole 243 avoided branch to sjmp