Daniel Jacobowitz wrote: > On Wed, Feb 06, 2008 at 10:59:12AM -0500, Kenneth Zadeck wrote: > >>> The final code generated appears something like the following. >>> >>> foo: >>> cmpslt $c6,$zero,$c1 >>> brz $c6,$link >>> i2cs $c6,@MID_11(4660) >>> i2c $c6,@BOT_11(4660) >>> incsi $c1,-1 >>> .L5: >>> stw ($c3[0]),$c6 >>> addzi $c2,$c2,4 -----> This is a redundant add instruction. >>> addzi $c3,$c3,4 >>> brinzdec $c1,.L5 >>> brz $zero,$link >>> >>> >>> >> I am completely missing your question. i do not see any redundancy of >> the insn that you say is redundant. that insn is indexing thru in and >> the next insn is indexing thru res. >> >> Obviously i am missing something. >> > > Except the load from in has been removed (it's redundant); so only the > indexing is left. > > Sorry, you are correct.
There are two flavors of dce at the rtl level, they are called "fast" and "ud". The ud is an optimistic use def algorithm that is based on the ssa algorithm by Cyrton, Ferrrante .... By optimistic, i mean that it assumes that all code is dead unless proven live. However it is very expensive to maintain use-def chains unless you have ssa form underneath them, so this pass is only run once before combine. (it could be argued that this is the wrong place for that, but this would require a lot of measurement on many platforms. The logic here was that the most opportunities for this would be after the loop optimizations but the cleanups would be useful for combine.) An unused induction variable can only be removed by the optimistic code. The pessimistic version is much faster and is run many times at the rtl level. However it assumes that all insns are live unless they can be proven dead, so an induction var never dies. At the time that the optimistic pass is run, there is still a real use of this register in insn 43. So the optimistic pass cannot get rid of insn 57. Kenny This can only be removed at the tree level.