https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121685
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- So the actual testcase (from CPU 2017 leela) is more like the following where IMO hoisting of the data start pointer should be OK since 'this' should be a valid object. #include <vector> class Foo { public: void fun (std::vector<int>& blacksq); std::vector<int> m_mcowner; }; void Foo::fun(std::vector<int>& blacksq) { for (unsigned int i = 0; i < blacksq.size(); i++) if (blacksq[i]) m_mcowner[i]++; } and the IL we get into if-coversion before vectorization is <bb 3> [local count: 1014280150]: # _18 = PHI <_4(12), 0(13)> # i_17 = PHI <i_14(12), 0(13)> _12 = _18 * 4; _10 = _26 + _12; _1 = *_10; if (_1 != 0) goto <bb 4>; [50.00%] else goto <bb 5>; [50.00%] <bb 4> [local count: 507140075]: _15 = MEM[(struct vector *)this_11(D)].D.27775._M_impl.D.27090._M_start; _16 = _15 + _12; _2 = *_16; _3 = _2 + 1; *_16 = _3; <bb 5> [local count: 1014280150]: i_14 = i_17 + 1; _4 = (long unsigned int) i_14; if (_4 < _21) goto <bb 12>; [94.50%] here hoisting of MEM[(struct vector *)this_11(D)].D.27775._M_impl.D.27090._M_start out of the loop should be OK.