http://d.puremagic.com/issues/show_bug.cgi?id=10685
--- Comment #1 from [email protected] 2013-07-20 14:22:09 PDT --- This range propagation is also useful for array bounds. See this code: void main() { int[100] a; foreach (immutable i; 0 .. 10) a[i] = 1; } Compiled with DMD gives: _D4test7__arrayZ: L0: enter 4,0 push EAX mov ECX,offset FLAT:_D4test12__ModuleInfoZ push ECX call near ptr __d_array_bounds __Dmain: L0: enter 0198h,0 push EBX push ESI push EDI mov ECX,064h xor EAX,EAX lea EDI,-0198h[EBP] rep stosd mov -8[EBP],EAX L19: cmp dword ptr -8[EBP],0Ah jge L4B mov ECX,-8[EBP] mov -4[EBP],ECX mov EDX,-4[EBP] cmp EDX,064h jb L37 mov EAX,4 call near ptr _D4test7__arrayZ L37: mov EBX,1 mov ESI,-4[EBP] mov -0198h[ESI*4][EBP],EBX inc dword ptr -8[EBP] jmp short L19 L4B: xor EAX,EAX pop EDI pop ESI pop EBX leave ret If the range of 'i' is propagated dmd could generate code like, thanks to Issue 9097 already implemented: __Dmain: enter 0198h,0 push EBX push EDI mov ECX,064h xor EAX,EAX lea EDI,-0198h[EBP] rep stosd mov -8[EBP],EAX L18: cmp dword ptr -8[EBP],0Ah jge L38 mov ECX,-8[EBP] mov -4[EBP],ECX mov EDX,1 mov EBX,-4[EBP] mov -0198h[EBX*4][EBP],EDX inc dword ptr -8[EBP] jmp short L18 L38: xor EAX,EAX pop EDI pop EBX leave ret -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
