On Tue, Jun 2, 2009 at 8:10 AM, bearophile <[email protected]> wrote: > Walter Bright: >>Dead assignment elimination is compiler technology from the 70's !< > > I'd like to see this technology used for arrays too. So in the following two > adjacent lines of code "a" doesn't get initialized to zero before being > initialized again to 5: > > void main() { > auto a = new int[10]; > a[] = 5; > printf("%d\n", a[3]); > } > > The ASM: > > sub ESP,01Ch > mov EAX,offset FLAT:_D11TypeInfo_Ai6__initZ > push 0Ah > push EAX > call near ptr __d_newarrayT > mov 0Ch[ESP],EAX > mov 010h[ESP],EDX > push dword ptr 0Ch[ESP] > push 5 > push EDX > mov 014h[ESP],EDX > call near ptr __memset32 > mov ECX,014h[ESP] > mov EDX,offset FLAT:_DATA > push dword ptr 0Ch[ECX] > push EDX > call near ptr _printf > [...]
As far as I know, LDC already does this.
