Extracted from tramp3d: template <class T> struct Bar { int get() { return static_cast<T*>(this)->get2(); } }; struct Foo : public Bar<Foo> { int get2() { return x; } int x; };
int foo(Foo& f) { return f.get(); } We end up with int foo(Foo&) (f) { struct Foo * this.1; int D.2027; struct Bar<Foo> * f.0; <bb 2>: f.0_2 = (struct Bar<Foo> *) f_1; this.1_4 = (struct Foo *) f.0_2; D.2027_6 = this.1_4->x; return D.2027_6; } while we can load x directly from f_1. This looks like something FRE should be able to do - tell that f_1 has the same VN as this.1_4 and (struct Foo *) f.0_2. Danny - does the new value-numbering catch this case? It can even strip const qualifiers for loads from the pointer. -- Summary: FRE does not value number effective types Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rguenth at gcc dot gnu dot org OtherBugsDependingO 22501 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27090