From: SourceForge.net <no...@so...> - 2004-08-11 19:35:29
|
Feature Requests item #966504, was opened at 2004-06-04 15:17 Message generated for change (Comment added) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=350599&aid=966504&group_id=599 Category: None Group: None Status: Open Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) >Summary: excessive push/pop between function calls Initial Comment: I has found several mistakes in SDCC: Source: #include <8052.h> unsigned char test; void test1(void) { //do something... } void test2(void) { //do something } void test3(void) { unsigned char tmp; for (tmp=0; tmp!=5; tmp++) { test1(); test2(); test1(); } } void main(void) { test3(); } SDCC run command: sdcc --verbose --model-small --peep-asm -mmcs51 -- iram-size 256 --xram-size 0 --code-size 12288 --nojtbound test.c SDCC version: SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51 /ds400/hc08 2.4.1 (Jun 3 2004) (MINGW32) Asm list: 388 ; --------------------------- -------------- 389 ; function test3 390 ; --------------------------- -------------- 0033 391 _test3: 392 ;test.c:18: for (tmp=0; tmp! =5; tmp++) 393 ; genAssign 0033 7A 00 394 mov r2,#0x00 0035 395 00101$: 396 ; genCmpEq 0035 BA 05 01 397 cjne r2,#0x05,00109$ 398 ; Peephole 112.b changed ljmp to sjmp 399 ; Peephole 251.b replaced sjmp to ret with ret 0038 22 400 ret 0039 401 00109$: 402 ;test.c:20: test1(); 403 ; genCall 0039 C0 02 404 push ar2 003B 12s00r31 405 lcall _test1 003E D0 02 406 pop ar2 <===== 407 ;test.c:21: test2 (); |spare operations with stack 408 ; genCall | 0040 C0 02 409 push ar2 <===== 0042 12s00r32 410 lcall _test2 0045 D0 02 411 pop ar2 <===== 412 ;test.c:22: test1 (); |spare operations with stack 413 ; genCall | 0047 C0 02 414 push ar2 <===== 0049 12s00r31 415 lcall _test1 004C D0 02 416 pop ar2 417 ;test.c:18: for (tmp=0; tmp! =5; tmp++) 418 ; genPlus 419 ; genPlusIncr 004E 0A 420 inc r2 421 ; Peephole 112.b changed ljmp to sjmp 004F 80 E4 422 sjmp 00101$ 0051 423 00105$: 0051 22 424 ret ---------------------------------------------------------------------- >Comment By: Maarten Brock (maartenbrock) Date: 2004-08-11 21:35 Message: Logged In: YES user_id=888171 Nice feature request, no bug ---------------------------------------------------------------------- Comment By: Yee_Keat Phuah (kiwlm) Date: 2004-07-12 07:47 Message: Logged In: YES user_id=940150 tmp is assigned in r2 in test3, and all the functions called by test3, might use r2 for other optimizations, hence test3 pushes r2 (or ar2) on the stack whenever it calls other functions. So I think this is normal. If you wishes to optimize it so that it only push/pop ar2 once in the whole loop, then its a different story, please clarify. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=350599&aid=966504&group_id=599 |