Bug 712480 - Incorrect common subexpression elimination in 4.6.0
Summary: Incorrect common subexpression elimination in 4.6.0
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 15
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-06-10 18:11 UTC by Tom Lane
Modified: 2013-07-03 03:37 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2011-06-13 11:27:32 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
gzip'd intermediate file. (133.75 KB, application/x-gzip)
2011-06-10 18:11 UTC, Tom Lane
no flags Details


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 49390 0 None None None Never

Description Tom Lane 2011-06-10 18:11:59 UTC
Created attachment 504181 [details]
gzip'd intermediate file.

Description of problem:
4.6.0 with -O2 incorrectly optimizes code of the following form:

   struct foo fooTmp;
   struct foo *fooPtr = &fooTmp;

   ...
   expression involving fooPtr->fld
   fooTmp.fld += something;
   same expression involving fooPtr->fld

The generated code assumes that the value fetched through fooPtr is still good after the update to the referenced variable.

The same code has worked fine in all previous gcc versions (it's out of postgresql FWIW)

Version-Release number of selected component (if applicable):
gcc-4.6.0-9.fc15.x86_64

How reproducible:
100%

Steps to Reproduce:
1.  Compile with /usr/bin/gcc -O2 -fno-strict-aliasing -fwrapv -g -I../../../../src/include -D_GNU_SOURCE  -c xlog.c
2. Inspect code for lines 3772, 3780, 3798

Additional info:
Unsurprisingly, -fno-gcse makes the bug go away.

I attach the .i file for the source code.

Comment 1 Jakub Jelinek 2011-06-13 11:27:32 UTC
I've so far distilled a small self-contained testcase from this, tracking upstream.


Note You need to log in before you can comment on or make changes to this bug.