Bug 707505

Summary: Optimiser produces incorrect code
Product: [Fedora] Fedora Reporter: Tom Hughes <tom>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 15CC: jakub
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-25 14:14:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
Test case none

Description Tom Hughes 2011-05-25 09:28:00 UTC
Created attachment 500766 [details]
Test case

Description of problem:

When the attached file is compiled with -ftree-vrp enabled, either manually or via -O2 or higher, the generated code produces incorrect results.

Version-Release number of selected component (if applicable):

gcc-4.6.0-7.fc15.x86_64

How reproducible:

Every time.

Steps to Reproduce:

1. Compile code with "cc -Wall -O3 -o fail fail.c"
2. Run "./fail 3", "./fail 4" and "./fail 6"
3. Compile code with "cc -Wall -O3 -fno-tree-vrp -o fail fail.c"
4. Run "./fail 3", "./fail 4" and "./fail 6" again
5. Compare results

Actual results:

for ./fail 3 - g i j k m
for ./fail 4 - g i j k m
for ./fail 6 - d g h i j k m

Expected results:

for ./fail 3 - g h j k m
for ./fail 4 - g i j k m
for ./fail 6 - d g h i j k m

Additional info:

This appears to go wrong in gcc 4.4.4 (from F12), 4.5.1 (from F14) and 4.6.0 (from F15) but not in 4.3.0 (from F9).

Comment 1 Jakub Jelinek 2011-05-25 14:14:42 UTC
Tracking this upstream as http://gcc.gnu.org/PR49161.