Update svn merge history.
[sdcc.git] / sdcc / src / hc08 / peeph.def
blob745c744060b0b8f45bbc92a3245934f7e9cba96b
1 replace {
2 pula
3 psha
4 lda %1
5 } by {
6 ; Peephole 1a - removed redundant pula/psha
7 lda %1
10 replace {
11 pula
12 psha
13 lda %1,s
14 } by {
15 ; Peephole 1b - removed redundant pula/psha
16 lda %1,s
19 replace {
20 pula
21 psha
22 clra
23 } by {
24 ; Peephole 1c - removed redundant pula/psha
25 clra
29 replace {
30 bcs %1
31 jmp %5
32 %1:
33 } by {
34 ; Peephole 2a - eliminated jmp
35 bcc %5
36 %1:
37 } if labelInRange(%5), labelRefCountChange(%1 -1)
39 replace {
40 bcc %1
41 jmp %5
42 %1:
43 } by {
44 ; Peephole 2b - eliminated jmp
45 bcs %5
46 %1:
47 } if labelInRange(%5), labelRefCountChange(%1 -1)
49 replace {
50 beq %1
51 jmp %5
52 %1:
53 } by {
54 ; Peephole 2c - eliminated jmp
55 bne %5
56 %1:
57 } if labelInRange(%5), labelRefCountChange(%1 -1)
59 replace {
60 bne %1
61 jmp %5
62 %1:
63 } by {
64 ; Peephole 2d - eliminated jmp
65 beq %5
66 %1:
67 } if labelInRange(%5), labelRefCountChange(%1 -1)
69 replace {
70 brclr %3,%2,%1
71 jmp %5
72 %1:
73 } by {
74 ; Peephole 2e - eliminated jmp
75 brset %3,%2,%5
76 %1:
77 } if labelInRange(%5), labelRefCountChange(%1 -1)
79 replace {
80 brset %3,%2,%1
81 jmp %5
82 %1:
83 } by {
84 ; Peephole 2f - eliminated jmp
85 brclr %3,%2,%5
86 %1:
87 } if labelInRange(%5), labelRefCountChange(%1 -1)
89 replace {
90 bls %1
91 jmp %5
92 %1:
93 } by {
94 ; Peephole 2g - eliminated jmp
95 bhi %5
96 %1:
97 } if labelInRange(%5), labelRefCountChange(%1 -1)
99 replace {
100 bhi %1
101 jmp %5
103 } by {
104 ; Peephole 2h - eliminated jmp
105 bls %5
107 } if labelInRange(%5), labelRefCountChange(%1 -1)
109 replace {
110 ble %1
111 jmp %5
113 } by {
114 ; Peephole 2i - eliminated jmp
115 bgt %5
117 } if labelInRange(%5), labelRefCountChange(%1 -1)
119 replace {
120 bgt %1
121 jmp %5
123 } by {
124 ; Peephole 2j - eliminated jmp
125 ble %5
127 } if labelInRange(%5), labelRefCountChange(%1 -1)
129 replace {
130 bge %1
131 jmp %5
133 } by {
134 ; Peephole 2k - eliminated jmp
135 blt %5
137 } if labelInRange(%5), labelRefCountChange(%1 -1)
139 replace {
140 blt %1
141 jmp %5
143 } by {
144 ; Peephole 2l - eliminated jmp
145 bge %5
147 } if labelInRange(%5), labelRefCountChange(%1 -1)
149 replace {
150 bmi %1
151 jmp %5
153 } by {
154 ; Peephole 2m - eliminated jmp
155 bpl %5
157 } if labelInRange(%5), labelRefCountChange(%1 -1)
159 replace {
160 bpl %1
161 jmp %5
163 } by {
164 ; Peephole 2n - eliminated jmp
165 bmi %5
167 } if labelInRange(%5), labelRefCountChange(%1 -1)
169 replace restart {
170 jmp %5
171 } by {
172 ; Peephole 3 - shortened jmp to bra
173 bra %5
174 } if labelInRange(%5)
176 replace {
177 lda %1
178 tsta
179 } by {
180 ; Peephole 4a - eliminated redundant tsta
181 lda %1
184 replace {
185 ldx %1
186 tstx
187 } by {
188 ; Peephole 4b - eliminated redundant tstx
189 ldx %1
192 replace {
193 jmp %5
194 } by {
195 ; Peephole 6a - replaced jmp to rts with rts
197 } if optimizeReturn(), labelIsReturnOnly(%5), labelRefCountChange(%5 -1)
199 replace {
200 bra %5
201 } by {
202 ; Peephole 6b - replaced jmp to rts with rts
204 } if optimizeReturn(), labelIsReturnOnly(%5), labelRefCountChange(%5 -1)
206 replace {
207 bne %1
209 } by {
210 ; Peephole 7a - eliminated branch
212 } if labelRefCountChange(%1 -1)
214 replace {
215 beq %1
217 } by {
218 ; Peephole 7b - eliminated branch
220 } if labelRefCountChange(%1 -1)
222 replace restart {
223 bra %1
225 } by {
226 ; Peephole 7c - eliminated branch
228 } if labelRefCountChange(%1 -1)
230 replace restart {
231 bra %1
234 } by {
235 ; Peephole 7d - eliminated branch
238 } if labelRefCountChange(%1 -1)
240 replace {
241 cmp #%2
242 beq %1
243 } by {
244 ; Peephole 10a - combined cmp/beq
245 cbeqa #%2,%1
248 replace {
249 cmp *%2
250 beq %1
251 } by {
252 ; Peephole 10b - combined cmp/beq
253 cbeq *%2,%1
256 replace {
257 dec %2,s
258 bne %1
259 } by {
260 ; Peephole 10c - combined dec/bne
261 dbnz %2,s,%1
264 // should be one of the last peepholes
265 replace restart {
267 } by {
268 ; Peephole 500 removed redundant label %1
269 } if labelRefCount(%1 0)
271 replace restart {
272 jsr %1
274 } by {
275 ; Peephole 501 did tail call optimization.
276 jmp %1
277 } if optimizeReturn()