https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80705
Bug ID: 80705
Summary: Incorrect code generated for profile counter updates
due to SLP+LIM
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pthaugen at gcc dot gnu.org
CC: dje at gcc dot gnu.org, wschmidt at gcc dot gnu.org
Target Milestone: ---
Host: powerpc64le-unknown-linux-gnu
Target: powerpc64le-unknown-linux-gnu
Build: powerpc64le-unknown-linux-gnu
Created attachment 41338
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41338&action=edit
reduced testcase
The attached testcase shows a problem where profile counter updates are
incorrectly generated, which then leads to invalid profile info when the
original source is rebuilt with -fprofile-use.
Compile options used : -Ofast -mcpu=power8 -fprofile-generate
The problem occurs on the edge counter updates for the following inner loop:
while (*s && *s!='\r' && *s!='\n' && *s!='"')
SLP vectorization combines adjacent counter writes on the exit paths from the
loop into vector store operations. LIM then comes along and hoists the initial
counter read outside the outer loop. This causes the problem because when the
inner loop is entered again the edge counters are initialized to the values
originally read from memory (i.e. values when the function was originally
entered) NOT the updated counter values that were written to memory when
exiting the inner loop. Aliasing problem?