public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/61576] New: wrong code at -O3 on x86_64-linux-gnu
@ 2014-06-20 23:07 su at cs dot ucdavis.edu
  2014-06-23  7:59 ` [Bug tree-optimization/61576] [4.10 Regression] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-06-20 23:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61576

            Bug ID: 61576
           Summary: wrong code at -O3 on x86_64-linux-gnu
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk miscompiles the following testcase on x86_64-linux at -O3
in both 32-bit and 64-bit modes.  

This is a regression from 4.9.x.  

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 4.10.0 20140620 (experimental) [trunk revision 211848] (GCC) 
$ 
$ gcc-trunk -O2 small.c; a.out
0
$ gcc-4.9.0 -O3 small.c; a.out
0
$ 
$ gcc-trunk -O3 small.c; a.out
1
$ 

--------------------------------

int printf (const char *, ...);

volatile int a, b;
int c, d, e, f;

static int
fn1 ()
{
  if (b)
    {
      d++;
      e = c || f;
    }
  return 0;
}

int
main ()
{
  for (; a < 1; a++)
    {
      fn1 ();
      continue;
    }
  printf ("%d\n", d);
  return 0;
}


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

* [Bug tree-optimization/61576] [4.10 Regression] wrong code at -O3 on x86_64-linux-gnu
  2014-06-20 23:07 [Bug tree-optimization/61576] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2014-06-23  7:59 ` jakub at gcc dot gnu.org
  2014-06-23 10:41 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-06-23  7:59 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61576

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-06-23
                 CC|                            |chrbr at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org
   Target Milestone|---                         |4.10.0
            Summary|wrong code at -O3 on        |[4.10 Regression] wrong
                   |x86_64-linux-gnu            |code at -O3 on
                   |                            |x86_64-linux-gnu
     Ever confirmed|0                           |1

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Worked up to and including r209971, started to ICE with r209972, that got fixed
in r211263.  The wrong-code started in r211302.  Given that was a cost change,
supposedly this has been latent before?


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

* [Bug tree-optimization/61576] [4.10 Regression] wrong code at -O3 on x86_64-linux-gnu
  2014-06-20 23:07 [Bug tree-optimization/61576] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2014-06-23  7:59 ` [Bug tree-optimization/61576] [4.10 Regression] " jakub at gcc dot gnu.org
@ 2014-06-23 10:41 ` rguenth at gcc dot gnu.org
  2014-06-23 10:44 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-23 10:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61576

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, but it doesn't do any PHI hoisting.  -fno-tree-loop-if-convert fixes it,
-O2 -ftree-loop-if-convert breaks it.


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

* [Bug tree-optimization/61576] [4.10 Regression] wrong code at -O3 on x86_64-linux-gnu
  2014-06-20 23:07 [Bug tree-optimization/61576] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
  2014-06-23  7:59 ` [Bug tree-optimization/61576] [4.10 Regression] " jakub at gcc dot gnu.org
  2014-06-23 10:41 ` rguenth at gcc dot gnu.org
@ 2014-06-23 10:44 ` rguenth at gcc dot gnu.org
  2014-06-23 14:13 ` ysrumyan at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-06-23 10:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61576

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ysrumyan at gmail dot com

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
+Found cond scalar reduction.
+d.6_12 = d_lsm.14_16 + 1;


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

* [Bug tree-optimization/61576] [4.10 Regression] wrong code at -O3 on x86_64-linux-gnu
  2014-06-20 23:07 [Bug tree-optimization/61576] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (2 preceding siblings ...)
  2014-06-23 10:44 ` rguenth at gcc dot gnu.org
@ 2014-06-23 14:13 ` ysrumyan at gmail dot com
  2014-06-26  8:00 ` izamyatin at gmail dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ysrumyan at gmail dot com @ 2014-06-23 14:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61576

--- Comment #4 from Yuri Rumyantsev <ysrumyan at gmail dot com> ---
There is an issue with phi-node and reduction stmt - after r211302 new hammock
was inserted between reduction stmt and bb containing phi:

  <bb 6>:
  d.6_12 = d_lsm.14_17 + 1;
  if (c.8_13 != 0)
    goto <bb 7>;
  else
    goto <bb 8>;

  <bb 7>:

  <bb 8>:
  # iftmp.7_15 = PHI <1(7), _19(6)>

  <bb 9>:
  # d_lsm.14_16 = PHI <d_lsm.14_17(5), d.6_12(8)>

but algorithm for converting conditional scalar reduction assumes that basic
block containing reduction is one of predecessors of phi-block. I added check
on it and test is passed.

BTW I wonder why such code motion has been done - in fact, redundant
computations were introduced in loop, before this fix all computations related
to hammock were hoisted out off loop:

  <bb 4>:
  d_lsm.14_25 = d;
  c.8_13 = c;
  f.9_14 = f;
  _18 = f.9_14 != 0;
  _19 = (int) _18;
  iftmp.7_15 = c.8_13 != 0 ? 1 : _19;
  e_lsm.15_26 = e;

  <bb 5>:
  # d_lsm.14_17 = PHI <d_lsm.14_25(4), d_lsm.14_16(9)>
  # e_lsm.15_1 = PHI <e_lsm.15_26(4), e_lsm.15_24(9)>
  b.4_10 ={v} b;
  if (b.4_10 != 0)
    goto <bb 6>;
  else
    goto <bb 7>;

  <bb 6>:
  d.6_12 = d_lsm.14_17 + 1;

  <bb 7>:
  # d_lsm.14_16 = PHI <d_lsm.14_17(5), d.6_12(6)>
  # e_lsm.15_24 = PHI <e_lsm.15_1(5), iftmp.7_15(6)>

I will send for review patch after required testing completion.


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

* [Bug tree-optimization/61576] [4.10 Regression] wrong code at -O3 on x86_64-linux-gnu
  2014-06-20 23:07 [Bug tree-optimization/61576] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (3 preceding siblings ...)
  2014-06-23 14:13 ` ysrumyan at gmail dot com
@ 2014-06-26  8:00 ` izamyatin at gmail dot com
  2014-07-08  7:52 ` kyukhin at gcc dot gnu.org
  2014-11-19 13:50 ` [Bug tree-optimization/61576] [5 " rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: izamyatin at gmail dot com @ 2014-06-26  8:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61576

Igor Zamyatin <izamyatin at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |izamyatin at gmail dot com

--- Comment #5 from Igor Zamyatin <izamyatin at gmail dot com> ---
Patch is posted at http://gcc.gnu.org/ml/gcc-patches/2014-06/msg01866.html


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

* [Bug tree-optimization/61576] [4.10 Regression] wrong code at -O3 on x86_64-linux-gnu
  2014-06-20 23:07 [Bug tree-optimization/61576] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (4 preceding siblings ...)
  2014-06-26  8:00 ` izamyatin at gmail dot com
@ 2014-07-08  7:52 ` kyukhin at gcc dot gnu.org
  2014-11-19 13:50 ` [Bug tree-optimization/61576] [5 " rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: kyukhin at gcc dot gnu.org @ 2014-07-08  7:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61576

--- Comment #6 from Kirill Yukhin <kyukhin at gcc dot gnu.org> ---
Author: kyukhin
Date: Tue Jul  8 07:52:12 2014
New Revision: 212347

URL: https://gcc.gnu.org/viewcvs?rev=212347&root=gcc&view=rev
Log:
PR tree-optimization/61576

gcc/
    * tree-if-conv.c (is_cond_scalar_reduction): Add check that
    basic block containing reduction statement is predecessor
    of phi basi block.

gcc/testsuite/
    * gcc.dg/torture/pr61576.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr61576.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-if-conv.c


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

* [Bug tree-optimization/61576] [5 Regression] wrong code at -O3 on x86_64-linux-gnu
  2014-06-20 23:07 [Bug tree-optimization/61576] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
                   ` (5 preceding siblings ...)
  2014-07-08  7:52 ` kyukhin at gcc dot gnu.org
@ 2014-11-19 13:50 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-11-19 13:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61576

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

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

--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2014-11-19 13:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-20 23:07 [Bug tree-optimization/61576] New: wrong code at -O3 on x86_64-linux-gnu su at cs dot ucdavis.edu
2014-06-23  7:59 ` [Bug tree-optimization/61576] [4.10 Regression] " jakub at gcc dot gnu.org
2014-06-23 10:41 ` rguenth at gcc dot gnu.org
2014-06-23 10:44 ` rguenth at gcc dot gnu.org
2014-06-23 14:13 ` ysrumyan at gmail dot com
2014-06-26  8:00 ` izamyatin at gmail dot com
2014-07-08  7:52 ` kyukhin at gcc dot gnu.org
2014-11-19 13:50 ` [Bug tree-optimization/61576] [5 " rguenth 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).