#1026 Induction problem: assignments lost

closed
5
2006-01-17
2005-11-24
grasbon
No

Assignments lost.
-----------------

Version:
SDCC:
mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08
2.5.4 #1168 (Nov 24 2005) (MINGW32)

Call:
"sdcc Main.c"

In the following code, the assignments for 'i' in line
17 (i = 42) and line 24 (i = 24) of "main.c" are skipped.
Hence the P1-assignment in line 27 becomes wrong.

Here's the Main.c:
-------------------------

#include <8052.h>

void
main(void)
{
unsigned char i;
unsigned char u;
static code char c = '?';

u = 0;
while( 1 )
{ i=0;
switch( u )
{ case 0:
P1 = 0;
i = 42; // Absent in "main.asm"
break;
case 1:
while( c != 'x' && i < 9 ) i++;
break;
default:
P1 = 2;
i = 24; // Absent in "main.asm"
}
P1 = i;
u++;
}
}

-------------------------

Therefor have a look at Main.asm, line 380 ff:
------------
00101$:
;Main.c:16: P1 = 0;
; genAssign
mov _P1,#0x00
;Main.c:18: break;
---------
and line 416 ff:
---------
00107$:
;Main.c:23: P1 = 2;
; genAssign
mov _P1,#0x02
;Main.c:26: }
---------

To turn off the peephole optimizer (--no-peep) has no
effect.

Reimar Grasbon

Discussion

  • grasbon

    grasbon - 2005-11-24

    The Main.c

     
  • grasbon

    grasbon - 2005-11-25

    Logged In: YES
    user_id=1374486

    Additional info: A workaround for that problem (in my
    projects) is to disable the loop induction by using the
    "--noinduction" option for compiling.

    Reimar

     
  • Bernhard Held

    Bernhard Held - 2005-12-28
    • assigned_to: nobody --> bernhardheld
     
  • Bernhard Held

    Bernhard Held - 2006-01-17
    • labels: --> Icode generator
    • summary: Assignments lost. --> Induction problem: assignments lost
    • status: open --> closed
     
  • Bernhard Held

    Bernhard Held - 2006-01-17

    Logged In: YES
    user_id=203539

    Fixed in SDCCloop.c 1.47, sdcc build 1193

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks