public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/57829] New: Wrong constant folding
@ 2013-07-05 12:32 ishiura-compiler at ml dot kwansei.ac.jp
2013-07-05 13:13 ` [Bug tree-optimization/57829] " mikpe at it dot uu.se
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: ishiura-compiler at ml dot kwansei.ac.jp @ 2013-07-05 12:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57829
Bug ID: 57829
Summary: Wrong constant folding
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ishiura-compiler at ml dot kwansei.ac.jp
GCC 4.7.2 - 4.9.0 for i686 and x86_64 miscompiles the following code.
$ cat error.c
int main (void)
{
volatile int k = 1;
int t = 2 | ( ( k - 1) >> 31 );
if (t != 2) __builtin_abort();
return 0;
}
$ x86_64-unknown-linux-gnu-gcc-4.9.0 error.c -O1
$ ./a.out
Aborted (core dumped)
$ x86_64-unknown-linux-gnu-gcc-4.9.0 -v
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-4.9.0
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-4.9.0/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/hassy/gcc/configure
--prefix=/usr/local/x86_64-tools/gcc-4.9.0/
--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls
--enable-languages=c
Thread model: posix
gcc version 4.9.0 20130704 (experimental) (GCC)
The status of the other versions are as follows:
(x86_64)
GCC-4.7.2 Error
GCC-4.8.2 (prerelease) OK
GCC-4.9.0 (experimental) Error
(i686)
GCC-4.7.2 Error
GCC-4.8.2 (prerelease) Error
GCC-4.9.0 (experimental) Error
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/57829] Wrong constant folding
2013-07-05 12:32 [Bug tree-optimization/57829] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
@ 2013-07-05 13:13 ` mikpe at it dot uu.se
2013-07-05 14:41 ` [Bug rtl-optimization/57829] " jakub at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: mikpe at it dot uu.se @ 2013-07-05 13:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57829
Mikael Pettersson <mikpe at it dot uu.se> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikpe at it dot uu.se
--- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> ---
If I change it to return the computed value of t, I get wrong code for every
single gcc version from 4.9 down to 3.2.3 on both x86_64 and sparc64. For
int main (void)
{
volatile int k = 1;
int t = 2 | ( ( k - 1) >> 31 );
return t;
}
gcc-4.9 generates
main:
movl $1, -4(%rsp)
movl -4(%rsp), %eax
leal -1(%rax), %eax
sarl $31, %eax
ret
which completely loses all references to the "2 |" part.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/57829] Wrong constant folding
2013-07-05 12:32 [Bug tree-optimization/57829] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
2013-07-05 13:13 ` [Bug tree-optimization/57829] " mikpe at it dot uu.se
@ 2013-07-05 14:41 ` jakub at gcc dot gnu.org
2013-07-05 14:43 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-07-05 14:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57829
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Target Milestone|--- |4.7.4
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/57829] Wrong constant folding
2013-07-05 12:32 [Bug tree-optimization/57829] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
2013-07-05 13:13 ` [Bug tree-optimization/57829] " mikpe at it dot uu.se
2013-07-05 14:41 ` [Bug rtl-optimization/57829] " jakub at gcc dot gnu.org
@ 2013-07-05 14:43 ` jakub at gcc dot gnu.org
2013-07-08 8:51 ` jakub at gcc dot gnu.org
2013-12-26 23:13 ` steven at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-07-05 14:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57829
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |jakub at gcc dot gnu.org
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 30463
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30463&action=edit
gcc49-pr57829.patch
Sounds very old bug, svn blame shows r7224.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/57829] Wrong constant folding
2013-07-05 12:32 [Bug tree-optimization/57829] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
` (2 preceding siblings ...)
2013-07-05 14:43 ` jakub at gcc dot gnu.org
@ 2013-07-08 8:51 ` jakub at gcc dot gnu.org
2013-12-26 23:13 ` steven at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-07-08 8:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57829
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Mon Jul 8 08:11:08 2013
New Revision: 200768
URL: http://gcc.gnu.org/viewcvs?rev=200768&root=gcc&view=rev
Log:
PR rtl-optimization/57829
* simplify-rtx.c (simplify_binary_operation_1) <case IOR>: Ensure that
mask bits outside of mode are just sign-extension from mode to HWI.
* gcc.c-torture/execute/pr57829.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr57829.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/simplify-rtx.c
trunk/gcc/testsuite/ChangeLog
Author: jakub
Date: Mon Jul 8 08:15:01 2013
New Revision: 200770
URL: http://gcc.gnu.org/viewcvs?rev=200770&root=gcc&view=rev
Log:
PR rtl-optimization/57829
* simplify-rtx.c (simplify_binary_operation_1) <case IOR>: Ensure that
mask bits outside of mode are just sign-extension from mode to HWI.
* gcc.c-torture/execute/pr57829.c: New test.
Added:
branches/gcc-4_8-branch/gcc/testsuite/gcc.c-torture/execute/pr57829.c
Modified:
branches/gcc-4_8-branch/gcc/ChangeLog
branches/gcc-4_8-branch/gcc/simplify-rtx.c
branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
Author: jakub
Date: Mon Jul 8 08:17:35 2013
New Revision: 200773
URL: http://gcc.gnu.org/viewcvs?rev=200773&root=gcc&view=rev
Log:
PR rtl-optimization/57829
* simplify-rtx.c (simplify_binary_operation_1) <case IOR>: Ensure that
mask bits outside of mode are just sign-extension from mode to HWI.
* gcc.c-torture/execute/pr57829.c: New test.
Added:
branches/gcc-4_7-branch/gcc/testsuite/gcc.c-torture/execute/pr57829.c
Modified:
branches/gcc-4_7-branch/gcc/ChangeLog
branches/gcc-4_7-branch/gcc/simplify-rtx.c
branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug rtl-optimization/57829] Wrong constant folding
2013-07-05 12:32 [Bug tree-optimization/57829] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
` (3 preceding siblings ...)
2013-07-08 8:51 ` jakub at gcc dot gnu.org
@ 2013-12-26 23:13 ` steven at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: steven at gcc dot gnu.org @ 2013-12-26 23:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57829
Steven Bosscher <steven at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |cqfu at transmeta dot com
--- Comment #5 from Steven Bosscher <steven at gcc dot gnu.org> ---
*** Bug 29589 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-12-26 23:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-05 12:32 [Bug tree-optimization/57829] New: Wrong constant folding ishiura-compiler at ml dot kwansei.ac.jp
2013-07-05 13:13 ` [Bug tree-optimization/57829] " mikpe at it dot uu.se
2013-07-05 14:41 ` [Bug rtl-optimization/57829] " jakub at gcc dot gnu.org
2013-07-05 14:43 ` jakub at gcc dot gnu.org
2013-07-08 8:51 ` jakub at gcc dot gnu.org
2013-12-26 23:13 ` steven at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).