https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78485
Bug ID: 78485
Summary: Missed scalarization in simple read-from-clobber case
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: glisse at gcc dot gnu.org
Target Milestone: ---
#include <initializer_list>
static std::initializer_list<int> f(int i) { return { i }; }
int main() { auto c=f(-1); return 1+c.begin()[0]; }
This remains as
D.3093 ={v} {CLOBBER};
_1 = MEM[(const int *)&D.3093];
_3 = _1 + 1;
instead of becoming
_3 = SR.10_5(D) + 1;
so we don't warn about it. Ideally something like PRE/DOM would handle it in
the general case, but in this specific case, SRA would be sufficient. However,
it does not seem interested in scalarizing this variable:
! Disqualifying D.3093 - No scalar replacements to be created.
I am hoping that a minor tweak to the heuristic could let it handle this case.
We still wouldn't warn (see
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60517#c18) but we would be
close...