public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/58626] New: possible array wrong code bug
@ 2013-10-05  5:35 regehr at cs dot utah.edu
  2013-10-05 11:50 ` [Bug c/58626] " mikpelinux at gmail dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: regehr at cs dot utah.edu @ 2013-10-05  5:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58626
           Summary: possible array wrong code bug
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: regehr at cs dot utah.edu

[regehr@imp r106]$ gcc -O2 small.c ; ./a.out 
1
[regehr@imp r106]$ gcc -O3 small.c ; ./a.out 
0
[regehr@imp r106]$ cat small.c
int printf(const char *, ...);

int a[8][6] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 };
int b;

int main(void) 
{
  for (b = 0; b <= 1; b++) {
    a[1][3] = 0;
    int c;
    for (c = 0; c <= 1; c++) {
      a[c + 1][b] = a[c + 2][b];
    }
  }
  printf("%d\n", a[1][1]);
  return 0;
}
[regehr@imp r106]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/mnt/local/randomtest/compiler-install/gcc-r203223-install/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /users/regehr/z/compiler-source/gcc/configure
--prefix=/users/regehr/z/compiler-install/gcc-r203223-install
--enable-languages=c,c++ --enable-multilib
Thread model: posix
gcc version 4.9.0 20131005 (experimental) (GCC)


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

* [Bug c/58626] possible array wrong code bug
  2013-10-05  5:35 [Bug c/58626] New: possible array wrong code bug regehr at cs dot utah.edu
@ 2013-10-05 11:50 ` mikpelinux at gmail dot com
  2013-10-07  9:03 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mikpelinux at gmail dot com @ 2013-10-05 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Mikael Pettersson <mikpelinux at gmail dot com> ---
Started with r202775, still occurs with today's trunk.


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

* [Bug c/58626] possible array wrong code bug
  2013-10-05  5:35 [Bug c/58626] New: possible array wrong code bug regehr at cs dot utah.edu
  2013-10-05 11:50 ` [Bug c/58626] " mikpelinux at gmail dot com
@ 2013-10-07  9:03 ` mpolacek at gcc dot gnu.org
  2013-10-10 11:50 ` [Bug c/58626] [4.9 Regression] " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-10-07  9:03 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-10-07
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1


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

* [Bug c/58626] [4.9 Regression] possible array wrong code bug
  2013-10-05  5:35 [Bug c/58626] New: possible array wrong code bug regehr at cs dot utah.edu
  2013-10-05 11:50 ` [Bug c/58626] " mikpelinux at gmail dot com
  2013-10-07  9:03 ` mpolacek at gcc dot gnu.org
@ 2013-10-10 11:50 ` rguenth at gcc dot gnu.org
  2013-10-11 11:36 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-10 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
            Summary|possible array wrong code   |[4.9 Regression] possible
                   |bug                         |array wrong code bug

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine.


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

* [Bug c/58626] [4.9 Regression] possible array wrong code bug
  2013-10-05  5:35 [Bug c/58626] New: possible array wrong code bug regehr at cs dot utah.edu
                   ` (2 preceding siblings ...)
  2013-10-10 11:50 ` [Bug c/58626] [4.9 Regression] " rguenth at gcc dot gnu.org
@ 2013-10-11 11:36 ` rguenth at gcc dot gnu.org
  2013-10-16  9:25 ` [Bug tree-optimization/58626] " mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-11 11:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I have updated my do-proper-partition-dependencies patch and verified it fixes
this issue.  We now generate

  <bb 2>:
  __builtin_memmove (&MEM[(void *)&a + 24B], &MEM[(void *)&a + 48B], 8);

  <bb 3>:
  # b.0_10 = PHI <b.1_12(4), 0(2)>
  a[1][3] = 0;
  _25 = a[3][b.0_10];
  a[2][b.0_10] = _25;
  b.1_12 = b.0_10 + 1;
  if (b.1_12 <= 1)
    goto <bb 4>;
  else
    goto <bb 5>;

  <bb 4>:
  goto <bb 3>;

  <bb 5>:
  b = 2;
  _14 = a[1][1];
  if (_14 != 1)

note the inner loop is completely peeled before loop distribution and we see

  <bb 3>:
  # b.0_10 = PHI <b.1_12(4), 0(2)>
  a[1][3] = 0;
  _19 = a[2][b.0_10];
  a[1][b.0_10] = _19;
  _25 = a[3][b.0_10];
  a[2][b.0_10] = _25;
  b.1_12 = b.0_10 + 1;
  if (b.1_12 <= 1)

the patch still needs quite some TLC though.


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

* [Bug tree-optimization/58626] [4.9 Regression] possible array wrong code bug
  2013-10-05  5:35 [Bug c/58626] New: possible array wrong code bug regehr at cs dot utah.edu
                   ` (3 preceding siblings ...)
  2013-10-11 11:36 ` rguenth at gcc dot gnu.org
@ 2013-10-16  9:25 ` mpolacek at gcc dot gnu.org
  2013-10-25 11:51 ` rguenth at gcc dot gnu.org
  2013-10-25 12:31 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-10-16  9:25 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |tree-optimization

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
-> tree-optimization.


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

* [Bug tree-optimization/58626] [4.9 Regression] possible array wrong code bug
  2013-10-05  5:35 [Bug c/58626] New: possible array wrong code bug regehr at cs dot utah.edu
                   ` (4 preceding siblings ...)
  2013-10-16  9:25 ` [Bug tree-optimization/58626] " mpolacek at gcc dot gnu.org
@ 2013-10-25 11:51 ` rguenth at gcc dot gnu.org
  2013-10-25 12:31 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-25 11:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Fri Oct 25 11:51:11 2013
New Revision: 204062

URL: http://gcc.gnu.org/viewcvs?rev=204062&root=gcc&view=rev
Log:
2013-10-25  Richard Biener  <rguenther@suse.de>

    PR tree-optimization/58626
    * tree-loop-distribution.c (enum rdg_dep_type): Remove
    anti_dd, output_dd and input_dd.
    (struct rdg_edge): Remove level and relation members.
    (RDGE_LEVEL, RDGE_RELATION): Remove.
    (dot_rdg_1): Adjust.
    (create_rdg_edge_for_ddr): Remove.
    (create_rdg_edges_for_scalar): Adjust.
    (create_edge_for_control_dependence): Likewise.
    (create_rdg_edges): Split into ...
    (create_rdg_flow_edges): ... this
    (create_rdg_cd_edges): ... and this.
    (free_rdg): Adjust.
    (build_rdg): Likewise, do not compute data dependences or
    add edges for them.
    (pg_add_dependence_edges): New function.
    (pgcmp): Likewise.
    (distribute_loop): First apply all non-dependence based
    partition mergings.  Then compute dependences between partitions
    and merge and order partitions according to them.

    * gcc.dg/torture/pr58626.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr58626.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-loop-distribution.c


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

* [Bug tree-optimization/58626] [4.9 Regression] possible array wrong code bug
  2013-10-05  5:35 [Bug c/58626] New: possible array wrong code bug regehr at cs dot utah.edu
                   ` (5 preceding siblings ...)
  2013-10-25 11:51 ` rguenth at gcc dot gnu.org
@ 2013-10-25 12:31 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-10-25 12:31 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

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


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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-05  5:35 [Bug c/58626] New: possible array wrong code bug regehr at cs dot utah.edu
2013-10-05 11:50 ` [Bug c/58626] " mikpelinux at gmail dot com
2013-10-07  9:03 ` mpolacek at gcc dot gnu.org
2013-10-10 11:50 ` [Bug c/58626] [4.9 Regression] " rguenth at gcc dot gnu.org
2013-10-11 11:36 ` rguenth at gcc dot gnu.org
2013-10-16  9:25 ` [Bug tree-optimization/58626] " mpolacek at gcc dot gnu.org
2013-10-25 11:51 ` rguenth at gcc dot gnu.org
2013-10-25 12:31 ` 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).