Bug 56513 - Wrong code generation with -O3 on ARM
Summary: Wrong code generation with -O3 on ARM
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2013-03-03 18:44 UTC by Tim Kosse
Modified: 2013-03-04 13:24 UTC (History)
1 user (show)

See Also:
Host:
Target: arm
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Small test program exhibiting the problem (253 bytes, text/plain)
2013-03-03 18:44 UTC, Tim Kosse
Details
Preprocessed file (59.39 KB, application/octet-stream)
2013-03-03 18:47 UTC, Tim Kosse
Details
Compiler output (1.22 KB, application/octet-stream)
2013-03-03 18:48 UTC, Tim Kosse
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Kosse 2013-03-03 18:44:49 UTC
Created attachment 29571 [details]
Small test program exhibiting the problem

If I'm cross-compiling the attached sample-program using gcc 4.7.2 for ARM on an x86-64 system, the resulting binary behaves wrongly if -O3 is used.

Output with -O0:

value: -23
best:  -10000
a:     -68
value: -22
best:  -23
a:     -23

Output with -O3:

value: -23
best:  -10000
a:     -68
value: -22
best:  -23
a:     65513
BUG
Comment 1 Tim Kosse 2013-03-03 18:47:18 UTC
Created attachment 29572 [details]
Preprocessed file

Created using the following command:
arm-unknown-linux-gnueabi-g++ -v -save-temps -O3 bug.cpp
Comment 2 Tim Kosse 2013-03-03 18:48:49 UTC
Created attachment 29573 [details]
Compiler output

Output of arm-unknown-linux-gnueabi-g++ -v -save-temps -O3 bug.cpp
Comment 3 Tim Kosse 2013-03-03 18:55:20 UTC
Also happens with GCC 4.7.1 and 4.6.3.
Comment 4 Mikael Pettersson 2013-03-03 20:11:08 UTC
I can reproduce the wrong-code on armv5tel-linux-gnueabi with gcc-4.7-20130302 and gcc-4.6-20121109, but not with gcc-4.8-20130224.  I can't reproduce on x86_64, sparc64, aarch64, or m68k.
Comment 5 Mikael Pettersson 2013-03-03 23:26:49 UTC
The wrong-code stopped for 4.8 with r188526, the introduction and enabling of -ftree-coalesce-vars.  At that point the wrong-code reappears with -O3 -fno-tree-coalesce-vars, however with current trunk those options give correct code.  I'll investigate some more tomorrow.
Comment 6 Mikael Pettersson 2013-03-04 13:24:04 UTC
The wrong-code with -O3 -fno-tree-coalesce-vars stopped occurring at r190284, Richard Biener's large "Allow anonymous SSA names" patch.  The patch description mentions minor code generation differences, but it doesn't appear to contain actual wrong code fixes so the underlying issue may still be latent on trunk.