Menu

#1738 Dead code messing up live ranges and register allocation

closed-out-of-date
None
other
5
2018-08-25
2011-01-06
No

When compiling the attached sample, iCode 37 is dead. It writes iTemp1, which will never be read.

kilLDeadCode from SDCCopt.c doesn't catch this due to
/* 2. if assignment and result is a temp & isaddr then skip */
/* since this means array & pointer access, will be taken */
/* care of by alias analysis. */

and

/* if the result is a temp & isaddr then skip */
if (IC_RESULT (ic) && POINTER_SET (ic))
continue;

Then, in live range analysis, we mark Temp1 as alive at iCode 37, but no subsequent ones (findNextUse won't find a next use). Thus this problem increases register pressure unnecessarily.

I found and can reproduce this on the Z80, but it's probably there for all ports.

Philipp

Discussion

  • Philipp Klaus Krause

    Sample code. Compile e.g. using sdcc -mz80 --std-c99 --fverbose-asm --i-code-in-asm test.c

     
  • Philipp Klaus Krause

    • status: open --> closed-out-of-date
    • assigned_to: Philipp Klaus Krause
    • Category: --> other
     
  • Philipp Klaus Krause

    I cannot reproduce this in current SDCC [r10516]. It probably got fixed long ago.

    Philipp

     

Log in to post a comment.