From: SourceForge.net <no...@so...> - 2004-07-26 10:16:51
|
Bugs item #995347, was opened at 2004-07-21 18:14 Message generated for change (Comment added) made by maartenbrock You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=995347&group_id=599 Category: None Group: None Status: Closed Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: Waste mov in GenCast Initial Comment: SDCC codegeneration error: Source: #include <8051.h> static unsigned int work1; void test(unsigned char arg1, unsigned char arg2) { register unsigned int tmp1; //Waste mov in typecasting! tmp1=arg1 << 8; tmp1|=arg2; work1=tmp1; } void main(void) { test(7,3); } 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.2 (Jul 16 2004) (MINGW32) Asm list: 306 ;------------------------------ ------------------------------ 307 ;Allocation info for local variables in function 'test' 308 ;------------------------------ ------------------------------ 309 ;arg2 Allocated with name '_test_PARM_2' 310 ;arg1 Allocated to registers r2 311 ;tmp1 Allocated to registers r2 r3 312 ;------------------------------ ------------------------------ 313 ;test.c:5: void test(unsigned char arg1, unsigned char arg2) 314 ; --------------------------- -------------- 315 ; function test 316 ; --------------------------- -------------- 0031 317 _test: 0002 318 ar2 = 0x02 0003 319 ar3 = 0x03 0004 320 ar4 = 0x04 0005 321 ar5 = 0x05 0006 322 ar6 = 0x06 0007 323 ar7 = 0x07 0000 324 ar0 = 0x00 0001 325 ar1 = 0x01 326 ; genReceive 0031 AA 82 327 mov r2,dpl 328 ;test.c:9: tmp1=arg1 << 8; 329 ; genCast ------------------------------------------------------- --- 0033 7B 00 330 mov r3,#0x00 Waste mov! ------------------------------------------------------- --- 331 ; genLeftShift 332 ; genLeftShiftLiteral 333 ; genlshTwo ------------------------------------------------------- --- 0035 8A 03 334 mov ar3,r2 0037 7A 00 335 mov r2,#0x00 ------------------------------------------------------- --- 336 ;test.c:10: tmp1|=arg2; 337 ; genCast 0039 AC*00 338 mov r4,_test_PARM_2 003B 7D 00 339 mov r5,#0x00 340 ; genOr 003D EC 341 mov a,r4 003E 4A 342 orl a,r2 003F F5*00 343 mov _work1,a 0041 ED 344 mov a,r5 0042 4B 345 orl a,r3 0043 F5*01 346 mov (_work1 + 1),a 347 ;test.c:11: work1=tmp1; 0045 348 00101$: 0045 22 349 ret I'm fix this bug by peephole rule: replace { mov %1,%2 mov a%1,%3 } by { ; peephole r.1 mov a%1,%3 } ---------------------------------------------------------------------- >Comment By: Maarten Brock (maartenbrock) Date: 2004-07-26 12:16 Message: Logged In: YES user_id=888171 Unfortunately that is not the instruction you throw away. It's mov r%1,%2 in your fix. That could very well be MOV Rn,direct. Any SFR will do here as %2 ! ---------------------------------------------------------------------- Comment By: Frieder Ferlemann (frief) Date: 2004-07-26 11:55 Message: Logged In: YES user_id=589052 Hi Maarten, no it should be OK. No SDCC generated symbol (save for acc) matches mov a%1, (unless I'm mistaken that is) Frieder ---------------------------------------------------------------------- Comment By: Maarten Brock (maartenbrock) Date: 2004-07-26 11:30 Message: Logged In: YES user_id=888171 Frieder, Shouldn't you check some volatileness here before throwing away a read instruction on %2 ? Maarten ---------------------------------------------------------------------- Comment By: Frieder Ferlemann (frief) Date: 2004-07-26 00:32 Message: Logged In: YES user_id=589052 added contributed fix for "bug" #995347 as peephole 177.e. Thanks to anonymous! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=995347&group_id=599 |