public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
@ 2011-05-24 13:38 doko at ubuntu dot com
  2011-05-24 15:29 ` [Bug tree-optimization/49140] " rguenth at gcc dot gnu.org
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: doko at ubuntu dot com @ 2011-05-24 13:38 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

           Summary: [4.6 regression] wrong code with -O2 and -O3, not with
                    -O3 -no-inline
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: doko@ubuntu.com


Created attachment 24342
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24342
preprocessed source

[forwarded from http://bugs.debian.org/627084]

seen with r174102 from the 4.6 branch, works with r173903 from the trunk


Step to reproduce:

wget 'http://pari.math.u-bordeaux.fr/~bill/pari-2.4.3.12000.tar.gz'
tar xf pari-2.4.3.12000.tar.gz
cd pari-2.4.3.alpha
./Configure
make gp
make bench

Result: all test suite fail.

Cause: 

The function pari_init_parser() in the file src/language/parsec.h is
miscompiled.
(This file is included by src/language/parse.y).

If you replace the line 43: s_node.n=OPnboperator; by parsestate_reset(); 
(which does the same thing), then all test pass.

It seems that the issue is that the function stack_alloc() is not inlined
correctly,
which cause pari_tree to be NULL (or maybe the call to pari_inline inside
stack_alloc()
is not inlined correctly.

The command line used is
gcc-4.6  -c -O3 -Wall -fno-strict-aliasing -fomit-frame-pointer    -I.
-I../src/headers -fPIC -o
parse.o ../src/language/parse.c

It also happens with -O2, but not with -O3 -fno-inline.

It works fine with gcc 4.3, 4.4 and 4.5.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
@ 2011-05-24 15:29 ` rguenth at gcc dot gnu.org
  2011-06-12 12:44 ` rguenth at gcc dot gnu.org
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-24 15:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-24 14:53:29 UTC ---
stack_init computes &pari_tree - &s_node which is undefined, stack_alloc
then re-computes one via stack_base.  That's broken as well.

Not sure if this eventually causes the issue, but certainly the code is
full of C implementation details that you can't capture in standard C.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
  2011-05-24 15:29 ` [Bug tree-optimization/49140] " rguenth at gcc dot gnu.org
@ 2011-06-12 12:44 ` rguenth at gcc dot gnu.org
  2011-06-12 14:29 ` hjl.tools at gmail dot com
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-06-12 12:44 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |49330
   Target Milestone|---                         |4.6.1

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-06-12 12:41:59 UTC ---
Maybe related to PR49330.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
  2011-05-24 15:29 ` [Bug tree-optimization/49140] " rguenth at gcc dot gnu.org
  2011-06-12 12:44 ` rguenth at gcc dot gnu.org
@ 2011-06-12 14:29 ` hjl.tools at gmail dot com
  2011-06-27 15:57 ` jakub at gcc dot gnu.org
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: hjl.tools at gmail dot com @ 2011-06-12 14:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> 2011-06-12 14:28:32 UTC ---
It is triggered by revision 158045:

http://gcc.gnu.org/ml/gcc-cvs/2010-04/msg00148.html


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (2 preceding siblings ...)
  2011-06-12 14:29 ` hjl.tools at gmail dot com
@ 2011-06-27 15:57 ` jakub at gcc dot gnu.org
  2011-07-14 22:10 ` grokbrsm at free dot fr
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-06-27 15:57 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.6.1                       |4.6.2

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-06-27 12:32:48 UTC ---
GCC 4.6.1 is being released.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (3 preceding siblings ...)
  2011-06-27 15:57 ` jakub at gcc dot gnu.org
@ 2011-07-14 22:10 ` grokbrsm at free dot fr
  2011-07-18  8:02 ` rguenth at gcc dot gnu.org
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: grokbrsm at free dot fr @ 2011-07-14 22:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Sébastien Kunz-Jacques <grokbrsm at free dot fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |grokbrsm at free dot fr

--- Comment #5 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-14 22:09:11 UTC ---
(In reply to comment #4)
> GCC 4.6.1 is being released.

I see a similar bug with both gcc 4.6.0 and 4.6.1. In the library crypto++ (v.
5.6.1, http://www.cryptopp.com/), the algorithm Salsa20 produces wrong outputs
when compiling with -O, -O2, -O3, but the bug dissapears as soon as -fno-inline
is added. The output is always correct with gcc 4.5.x. These results were
obtained on a 64-bit linux platform (ubuntu 11.04). 

I cannot post the source code that produces the errors; I do not have a reduced
test case.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (4 preceding siblings ...)
  2011-07-14 22:10 ` grokbrsm at free dot fr
@ 2011-07-18  8:02 ` rguenth at gcc dot gnu.org
  2011-07-18 10:20 ` doko at ubuntu dot com
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-07-18  8:02 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2011.07.18 08:02:02
     Ever Confirmed|0                           |1

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-18 08:02:02 UTC ---
This PR lacks an executable testcase for easy verification of the bug.

Thus, can people try with the fix for PR49651 installed?


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (5 preceding siblings ...)
  2011-07-18  8:02 ` rguenth at gcc dot gnu.org
@ 2011-07-18 10:20 ` doko at ubuntu dot com
  2011-07-18 19:55 ` grokbrsm at free dot fr
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: doko at ubuntu dot com @ 2011-07-18 10:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #7 from Matthias Klose <doko at ubuntu dot com> 2011-07-18 10:19:28 UTC ---
the pari tests still fail


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (6 preceding siblings ...)
  2011-07-18 10:20 ` doko at ubuntu dot com
@ 2011-07-18 19:55 ` grokbrsm at free dot fr
  2011-07-18 20:00 ` grokbrsm at free dot fr
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: grokbrsm at free dot fr @ 2011-07-18 19:55 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #8 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-18 19:55:29 UTC ---
Created attachment 24790
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24790
test case with Salsa20 in Crypto++


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (7 preceding siblings ...)
  2011-07-18 19:55 ` grokbrsm at free dot fr
@ 2011-07-18 20:00 ` grokbrsm at free dot fr
  2011-07-19  8:06 ` rguenth at gcc dot gnu.org
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: grokbrsm at free dot fr @ 2011-07-18 20:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #9 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-18 19:59:35 UTC ---
(In reply to comment #8)
> Created attachment 24790 [details]
> test case with Salsa20 in Crypto++

Sorry about my partial comment. Used the test case on source of gcc 4.6.1 +
patch for PR49651 (applied the patch as found at
http://gcc.gnu.org/viewcvs?view=revision&revision=176274 to
tree-ssa-structalias.c), still does not work.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (8 preceding siblings ...)
  2011-07-18 20:00 ` grokbrsm at free dot fr
@ 2011-07-19  8:06 ` rguenth at gcc dot gnu.org
  2011-07-19 16:13 ` grokbrsm at free dot fr
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-07-19  8:06 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #10 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-19 08:05:42 UTC ---
Can you attach preprocessed source of the Salsa20 testcase please?


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (9 preceding siblings ...)
  2011-07-19  8:06 ` rguenth at gcc dot gnu.org
@ 2011-07-19 16:13 ` grokbrsm at free dot fr
  2011-07-19 16:15 ` grokbrsm at free dot fr
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: grokbrsm at free dot fr @ 2011-07-19 16:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #11 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-19 16:12:14 UTC ---
Created attachment 24793
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24793
the preprocessed source of salsa20 from Crypto++ with gcc 4.5.1, option -O2


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (10 preceding siblings ...)
  2011-07-19 16:13 ` grokbrsm at free dot fr
@ 2011-07-19 16:15 ` grokbrsm at free dot fr
  2011-07-20  6:08 ` grokbrsm at free dot fr
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: grokbrsm at free dot fr @ 2011-07-19 16:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #12 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-19 16:14:29 UTC ---
Created attachment 24794
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24794
the preprocessed source of Salsa20 from Crypto++, with gcc 4.6.0, option -O2


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (11 preceding siblings ...)
  2011-07-19 16:15 ` grokbrsm at free dot fr
@ 2011-07-20  6:08 ` grokbrsm at free dot fr
  2011-07-20  7:11 ` grokbrsm at free dot fr
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: grokbrsm at free dot fr @ 2011-07-20  6:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #13 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-20 06:07:39 UTC ---
(In reply to comment #12)
> Created attachment 24794 [details]
> the preprocessed source of Salsa20 from Crypto++, with gcc 4.6.0, option -O2

I just discovered that the bug is present only when crypto++ is compiled with
NDEBUG defined, which is not the case in the preprocessed files above. I will
re-post updated files (output of the whole compilation of test case with
-save-temps).


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (12 preceding siblings ...)
  2011-07-20  6:08 ` grokbrsm at free dot fr
@ 2011-07-20  7:11 ` grokbrsm at free dot fr
  2011-07-20  8:45 ` rguenther at suse dot de
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: grokbrsm at free dot fr @ 2011-07-20  7:11 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #14 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-20 07:09:53 UTC ---
Created attachment 24796
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24796
full testcase source with required files from Crypto++ 5.6.1 and build command

the (slightly modified) testcase with Crypto++ 5.6.1, this time self-contained.
All files except gcc_pr49140.cpp are unmodified form Crypto++.
build command is in build.sh, with option -save-temps.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (13 preceding siblings ...)
  2011-07-20  7:11 ` grokbrsm at free dot fr
@ 2011-07-20  8:45 ` rguenther at suse dot de
  2011-07-20  9:24 ` rguenth at gcc dot gnu.org
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: rguenther at suse dot de @ 2011-07-20  8:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #15 from rguenther at suse dot de <rguenther at suse dot de> 2011-07-20 08:44:33 UTC ---
On Tue, 19 Jul 2011, grokbrsm at free dot fr wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140
> 
> --- Comment #12 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-19 16:14:29 UTC ---
> Created attachment 24794
>   --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24794
> the preprocessed source of Salsa20 from Crypto++, with gcc 4.6.0, option -O2

Hm, unfortunately these don't seem to be self-contained (they fail to
link).


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (14 preceding siblings ...)
  2011-07-20  8:45 ` rguenther at suse dot de
@ 2011-07-20  9:24 ` rguenth at gcc dot gnu.org
  2011-07-20 10:10 ` grokbrsm at free dot fr
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-07-20  9:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
      Known to fail|                            |4.6.1

--- Comment #16 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-07-20 09:22:45 UTC ---
Confirmed.  Works with -O0, fails with -O[12] at least.  Still fails on the
4.6 branch.

Compiling salsa.cpp with -O1 is enough to trigger the error, compiling
salsa.cpp with -O0 is enough to mitigate it.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (15 preceding siblings ...)
  2011-07-20  9:24 ` rguenth at gcc dot gnu.org
@ 2011-07-20 10:10 ` grokbrsm at free dot fr
  2011-07-20 17:29 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: grokbrsm at free dot fr @ 2011-07-20 10:10 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #17 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-20 10:09:54 UTC ---
(In reply to comment #16)
> Confirmed.  Works with -O0, fails with -O[12] at least.  Still fails on the
> 4.6 branch.
> 
> Compiling salsa.cpp with -O1 is enough to trigger the error, compiling
> salsa.cpp with -O0 is enough to mitigate it.

yes, the wrong code is most probably generated in method
Salsa20_Policy::OperateKeystream of salsa.cpp.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (16 preceding siblings ...)
  2011-07-20 10:10 ` grokbrsm at free dot fr
@ 2011-07-20 17:29 ` jakub at gcc dot gnu.org
  2011-07-20 17:40 ` jakub at gcc dot gnu.org
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-20 17:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-20 17:26:11 UTC ---
The inline asm in that function is invalid:
   :
   : "r" (m_rounds), "r" (input), "r" (iterationCount), "r" (m_state.data()),
"r" (output), "r" (workspace.m_ptr)
   : "%eax", "%edx", "memory", "cc", "%xmm0", "%xmm1", "%xmm2", "%xmm3",
"%xmm4", "%xmm5", "%xmm6", "%xmm7", "%xmm8", "%xmm9", "%xmm10", "%xmm11",

It tells the compiler that it only uses the 6 input registers, while it
modifies 3 of them, e.g. the asm string contains:
"add %1" ", " "1*16" ";"
"sub %2" ", " "4" ";"
"add %4" ", " "1*16" ";"

GCC can assume that it will find the old content in the register after the
inline asm and will find there something completely different.
For the inputs that are clobbered, the pattern should use something like:
void *dummy1;
... asm volatile ("..." : "=r" (dummy1) : "0" (input_value));
to say that it can't be used.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (17 preceding siblings ...)
  2011-07-20 17:29 ` jakub at gcc dot gnu.org
@ 2011-07-20 17:40 ` jakub at gcc dot gnu.org
  2011-07-20 17:43 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-20 17:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID

--- Comment #19 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-20 17:39:11 UTC ---
And that isn't the only bug in it, the inline asm also performs calls (which
modify the bytes right below the stack), but when this function is compiled
with -O1 and above (and not without -fno-inline), the function makes no
function calls, therefore it happily uses red-zone and the embedded calls in
the inline asm clobber the red-zone.  Adding "sub rsp, 128;" and "add rsp,
128;" around the
whole inline asm content well, inside of the intel syntax, fixes the testcase
(of course, as written in the previous comment, it is still broken).


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (18 preceding siblings ...)
  2011-07-20 17:40 ` jakub at gcc dot gnu.org
@ 2011-07-20 17:43 ` jakub at gcc dot gnu.org
  2011-07-20 21:24 ` grokbrsm at free dot fr
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-07-20 17:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |

--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-07-20 17:43:36 UTC ---
Ah, the crypto++ comments were just hijacking an unrelated bug for which no
details have been provided.  Please don't do this.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (19 preceding siblings ...)
  2011-07-20 17:43 ` jakub at gcc dot gnu.org
@ 2011-07-20 21:24 ` grokbrsm at free dot fr
  2011-08-01 14:40 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: grokbrsm at free dot fr @ 2011-07-20 21:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #21 from Sébastien Kunz-Jacques <grokbrsm at free dot fr> 2011-07-20 21:23:42 UTC ---
(In reply to comment #20)
> Ah, the crypto++ comments were just hijacking an unrelated bug for which no
> details have been provided.  Please don't do this.

Well, the symptoms looked similar: the error also dissapears with -fno-inline,
so that it matches the bug report header pretty well. I'll file a bug report
for Crypto++.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (20 preceding siblings ...)
  2011-07-20 21:24 ` grokbrsm at free dot fr
@ 2011-08-01 14:40 ` rguenth at gcc dot gnu.org
  2011-10-16 14:40 ` mans at mansr dot com
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-01 14:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |WAITING

--- Comment #22 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-01 14:36:43 UTC ---
Waiting for a testcase.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (21 preceding siblings ...)
  2011-08-01 14:40 ` rguenth at gcc dot gnu.org
@ 2011-10-16 14:40 ` mans at mansr dot com
  2011-10-26 17:24 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 27+ messages in thread
From: mans at mansr dot com @ 2011-10-16 14:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

--- Comment #23 from Mans Rullgard <mans at mansr dot com> 2011-10-16 14:40:29 UTC ---
Created attachment 25516
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25516
Small test case with invalid code exhibiting the problem

Here's a small test case with invalid code showing the problem with several gcc
versions going back at least to 4.5.  Compiling with -fno-tree-pta makes it
behave as "expected".

I do not believe the compiler to be at fault here.  PARI is clearly full of
undefined behaviours they really ought to fix rather than complain that doing
so would change the ABI and blame the compiler which is only doing a good job
following the spec.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (22 preceding siblings ...)
  2011-10-16 14:40 ` mans at mansr dot com
@ 2011-10-26 17:24 ` jakub at gcc dot gnu.org
  2012-03-01 15:15 ` jakub at gcc dot gnu.org
  2013-04-12 16:31 ` jakub at gcc dot gnu.org
  25 siblings, 0 replies; 27+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-10-26 17:24 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.6.2                       |4.6.3

--- Comment #24 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-10-26 17:13:34 UTC ---
GCC 4.6.2 is being released.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (23 preceding siblings ...)
  2011-10-26 17:24 ` jakub at gcc dot gnu.org
@ 2012-03-01 15:15 ` jakub at gcc dot gnu.org
  2013-04-12 16:31 ` jakub at gcc dot gnu.org
  25 siblings, 0 replies; 27+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-03-01 15:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.6.3                       |4.6.4

--- Comment #25 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-03-01 14:38:25 UTC ---
GCC 4.6.3 is being released.


^ permalink raw reply	[flat|nested] 27+ messages in thread

* [Bug tree-optimization/49140] [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline
  2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
                   ` (24 preceding siblings ...)
  2012-03-01 15:15 ` jakub at gcc dot gnu.org
@ 2013-04-12 16:31 ` jakub at gcc dot gnu.org
  25 siblings, 0 replies; 27+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-12 16:31 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49140

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|4.6.4                       |4.7.0

--- Comment #26 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-12 16:31:36 UTC ---
The 4.6 branch has been closed, fixed in GCC 4.7.0.


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2013-04-12 16:31 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-24 13:38 [Bug tree-optimization/49140] New: [4.6 regression] wrong code with -O2 and -O3, not with -O3 -no-inline doko at ubuntu dot com
2011-05-24 15:29 ` [Bug tree-optimization/49140] " rguenth at gcc dot gnu.org
2011-06-12 12:44 ` rguenth at gcc dot gnu.org
2011-06-12 14:29 ` hjl.tools at gmail dot com
2011-06-27 15:57 ` jakub at gcc dot gnu.org
2011-07-14 22:10 ` grokbrsm at free dot fr
2011-07-18  8:02 ` rguenth at gcc dot gnu.org
2011-07-18 10:20 ` doko at ubuntu dot com
2011-07-18 19:55 ` grokbrsm at free dot fr
2011-07-18 20:00 ` grokbrsm at free dot fr
2011-07-19  8:06 ` rguenth at gcc dot gnu.org
2011-07-19 16:13 ` grokbrsm at free dot fr
2011-07-19 16:15 ` grokbrsm at free dot fr
2011-07-20  6:08 ` grokbrsm at free dot fr
2011-07-20  7:11 ` grokbrsm at free dot fr
2011-07-20  8:45 ` rguenther at suse dot de
2011-07-20  9:24 ` rguenth at gcc dot gnu.org
2011-07-20 10:10 ` grokbrsm at free dot fr
2011-07-20 17:29 ` jakub at gcc dot gnu.org
2011-07-20 17:40 ` jakub at gcc dot gnu.org
2011-07-20 17:43 ` jakub at gcc dot gnu.org
2011-07-20 21:24 ` grokbrsm at free dot fr
2011-08-01 14:40 ` rguenth at gcc dot gnu.org
2011-10-16 14:40 ` mans at mansr dot com
2011-10-26 17:24 ` jakub at gcc dot gnu.org
2012-03-01 15:15 ` jakub at gcc dot gnu.org
2013-04-12 16:31 ` jakub 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).