https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88677
Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|needs-reduction | --- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> --- Reduced test-case: $ cat test2.ii template <typename> class c; template <typename b> class D : public c<b> { public: static D d() { return D(0, e, f); } enum g { e }; enum h { f }; D(b *, g, h) : i() {} b i; }; struct j { int k; }; template <> class c<j> { public: void l(); }; extern const D<j> m; class n { unsigned o; public: D<j> p() { return o ? D<j>::d() : m; } }; void fn1() { n a; a.p().l(); a.p(); } Minimal options: -O2 Difference for -fdump-tree-fre1: $ diff -u 2 1 --- 2 2019-01-04 09:13:20.637935502 +0100 +++ 1 2019-01-04 09:13:17.961848506 +0100 @@ -57,7 +57,7 @@ n::p (struct n * const this) { int SR.3; - struct D D.2531; + struct D D.2527; struct D D.2507; unsigned int _1; @@ -108,9 +108,9 @@ int SR.8; int SR.7; unsigned int a; - struct D D.2547; - struct D D.2545; - struct D D.2544; + struct D D.2543; + struct D D.2541; + struct D D.2540; struct n a; struct D D.2498; struct D D.2497; @@ -140,7 +140,8 @@ SR.9_27 = MEM[(struct D *)&m]; <bb 7> : - MEM[(struct D *)&D.2498] = SR.8_11; + # SR.9_12 = PHI <0(5), SR.9_27(6)> + MEM[(struct D *)&D.2498] = SR.9_12; return; <bb 8> :