https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107138
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Last reconfirmed| |2022-12-22 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Priority|P3 |P2 --- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. We're diagnosing the read # VUSE <.MEM_106> _60 = MEM[(const struct basic_string *)&D.48280]._M_string_length; which happens conditional after the lifetime of D.48280 starts: MEM[(struct __as_base &)&D.48280] ={v} {CLOBBER}; MEM[(union _Variadic_union *)&D.48280] ={v} {CLOBBER}; MEM[(union _Variadic_union *)&D.48280] ={v} {CLOBBER}; MEM[(struct _Uninitialized *)&D.48280] ={v} {CLOBBER}; _128 = (void *) ivtmp.494_2; _19 = MEM[(const type &)_128]; MEM[(struct _Uninitialized *)&D.48280]._M_storage = _19; MEM[(struct _Variant_storage *)&D.48280]._M_index = 2; ... the condition chains is <bb 7> [local count: 668941184]: MEM[(struct _Variant_storage *)_35]._M_index = 255; _45 = D.48280.D.48091.D.47570.D.47488.D.47356.D.47242.D.47146._M_index; _46 = (signed char) _45; _47 = (long unsigned int) _46; if (_47 > 4) goto <bb 40>; [16.67%] else goto <bb 8>; [83.33%] <bb 8> [local count: 557450988]: switch (_45) <default: <L7> [20.00%], case 1: <L8> [20.00%], case 2: <L9> [20.00%], case 3: <L10> [20.00%], case 4: <L14> [20.00%]> <bb 9> [local count: 111490196]: <L7>: _57 = &MEM[(struct basic_string *)_35].D.36033._M_local_buf; MEM[(struct _Alloc_hider *)_35]._M_p = _57; _58 = MEM[(const struct basic_string *)&D.48280]._M_dataplus._M_p; if (&MEM[(const struct basic_string *)&D.48280].D.36033._M_local_buf == _58) goto <bb 10>; [30.00%] else goto <bb 12>; [70.00%] <bb 10> [local count: 33447058]: _60 = MEM[(const struct basic_string *)&D.48280]._M_string_length; in this case we have other stores possibly clobbering the _M_index store so we fail to statically optimize these branches (from the = 2 initializer which should be still there?).