Bug 921 – DMD should optimize calls to final members in derived classes

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-02-02T06:52:38Z
Last change time
2024-12-13T17:47:49Z
Keywords
backend, performance
Assigned to
No Owner
Creator
Nicolay Korslund
Moved to GitHub: dmd#17578 →

Comments

Comment #0 by korslund — 2007-02-02T06:52:38Z
Consider the following code: class A { final double caller(double d) { return callee(d); } double callee(double d) { return 0; } } class B : A { final double callee(double d) { // do some random math return (d*d - d/7.5)/d; } } void main() { B b = new B; for(ulong l; l<50000000uL; l++) b.caller(l); } Compile with -O -inline, and the function call to callee() is not inlined. This is because caller() is compiled in the context of class A, where callee() is a virtual function. I suggest that the optimizer should "recompile" caller() in the context of class B, so that B.caller() uses a inlined version while A.caller() does not. This is useful in eg. a linear algebra system, where a matrix base class has an abstract element() method for accessing elements, and several (final) standard operations that use element().
Comment #1 by dmitry.olsh — 2018-05-15T13:11:00Z
Still not inlined, after 10 years. But then there is LDC/GDC if one wants optimization.
Comment #2 by robert.schadek — 2024-12-13T17:47:49Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17578 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB