[Issue 6350] New: Const array static usage optimization
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 19 17:03:38 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6350
Summary: Const array static usage optimization
Product: D
Version: unspecified
Platform: All
OS/Version: Windows
Status: NEW
Severity: enhancement
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2011-07-19 16:58:20 PDT ---
A D2 program:
enum int[1] array1 = [10];
int foo(int[1] v) {
return array1[0] * v[0];
}
const int[1] array2 = [10];
int bar(int[1] v) {
return array2[0] * v[0];
}
void main() {}
The asm of the two functions (dmd 2.054, -O -release), inside bar() the
contents of array2 are loaded with a mov instruction:
_D4test3fooFG1iZi comdat
push EAX
lea EAX,[EAX*4][EAX]
add EAX,EAX
pop ECX
ret
_D4test3barFG1iZi comdat
push EAX
mov EAX,_D4test6array2xG1i
imul EAX,[ESP]
pop ECX
ret
Is it possible for the compiler for such common case of const array to remove
the mov instruction from the bar () function too?
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list