#1738 Dead code messing up live ranges and register allocation

open
nobody
None
5
2011-01-06
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

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

     
    Attachments