public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/47365] New: [4.5 Regression] wrong code with -O -ftree-pre
@ 2011-01-19 23:12 zsojka at seznam dot cz
  2011-01-20 10:55 ` [Bug tree-optimization/47365] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2011-01-19 23:12 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [4.5 Regression] wrong code with -O -ftree-pre
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zsojka@seznam.cz
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu


Created attachment 23035
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23035
reduced testcase

Reported by Vegard Nossum at IRC.

Output:
$ gcc-4.5 -O -ftree-pre testcase.c
$ ./a.out 
Aborted

In the testcase.c.092t.pre dump, there is:
...
<bb 2>:
  D.2739_4 = b.a[0].i;
  i.0_5 = i;
  if (D.2739_4 != i.0_5)
    goto <bb 3>;
  else
    goto <bb 4>;

<bb 3>:
  b.a[0] = b.a[1];
  b.a[1].i = D.2739_4;
  pretmp.3_6 = b.a[1].i;
  goto <bb 6>;

<bb 4>:
...
<bb 9>:

<bb 6>:
  # prephitmp.4_8 = PHI <D.2739_4(9), pretmp.3_6(3)>
  D.2739_9 = prephitmp.4_8;
  D.2739_9 = prephitmp.4_8;
  if (D.2739_9 == 0)
    goto <bb 7>;
...

Problematic line is
  pretmp.3_6 = b.a[1].i;
which reads the new value of "b.a[1].i". It should either happen one line
earlier, or it should read "b.a[0].i".

It seems that the fact "b.a[0] = b.a[1]" overwrites "b.a[0].i" is ignored.

Of couse I can be wrong.

Tested revisions:
r169006 - OK
4.5 r168785 - fail
4.4 r168785 - OK


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

* [Bug tree-optimization/47365] [4.5 Regression] wrong code with -O -ftree-pre
  2011-01-19 23:12 [Bug tree-optimization/47365] New: [4.5 Regression] wrong code with -O -ftree-pre zsojka at seznam dot cz
@ 2011-01-20 10:55 ` rguenth at gcc dot gnu.org
  2011-01-20 12:21 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-01-20 10:55 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.01.20 10:50:43
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
   Target Milestone|---                         |4.5.3
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-20 10:50:43 UTC ---
Confirmed and mine.


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

* [Bug tree-optimization/47365] [4.5 Regression] wrong code with -O -ftree-pre
  2011-01-19 23:12 [Bug tree-optimization/47365] New: [4.5 Regression] wrong code with -O -ftree-pre zsojka at seznam dot cz
  2011-01-20 10:55 ` [Bug tree-optimization/47365] " rguenth at gcc dot gnu.org
@ 2011-01-20 12:21 ` rguenth at gcc dot gnu.org
  2011-01-21  4:17 ` [Bug tree-optimization/47365] [4.5/4.6 " zsojka at seznam dot cz
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-01-20 12:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-20 12:01:23 UTC ---
What happens is that when translating D.2739_9 = b.a[0].i; from bb6 to
bb3 value-numbering does look through the aggregate copy b.a[0] = b.a[1];
continuing to look for b.a[1].i and finding D.2737_7 = b.a[1].i; from bb4
(which is ok - the consumer has to check availability).  Thus
b.a[1].i ends up in antic-out (not a problem) with a new value-number,
it doesn't end up in antic-in of bb3.

b.a[0].i is partially redundant in bb6, D.2739_4 is correctly found as
the available expression for it via bb6.  But when we translate
b.a[0].i to bb3 again during insertion we again obtain b.a[1].i
(because it's also still in the phi-translation cache).  It is
obviously not available here so we insert it.  Oops.

We don't prune invalid translations during insertion - that's the
basic problem.  We'd expect to find a leader as the translated
expression has a SCCVN value-number.

The problem is latent on trunk.


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

* [Bug tree-optimization/47365] [4.5/4.6 Regression] wrong code with -O -ftree-pre
  2011-01-19 23:12 [Bug tree-optimization/47365] New: [4.5 Regression] wrong code with -O -ftree-pre zsojka at seznam dot cz
  2011-01-20 10:55 ` [Bug tree-optimization/47365] " rguenth at gcc dot gnu.org
  2011-01-20 12:21 ` rguenth at gcc dot gnu.org
@ 2011-01-21  4:17 ` zsojka at seznam dot cz
  2011-01-21 14:08 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: zsojka at seznam dot cz @ 2011-01-21  4:17 UTC (permalink / raw)
  To: gcc-bugs

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

Zdenek Sojka <zsojka at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to work|4.6.0                       |
            Summary|[4.5 Regression] wrong code |[4.5/4.6 Regression] wrong
                   |with -O -ftree-pre          |code with -O -ftree-pre
      Known to fail|                            |4.6.0

--- Comment #3 from Zdenek Sojka <zsojka at seznam dot cz> 2011-01-21 00:06:51 UTC ---
(In reply to comment #2)
> The problem is latent on trunk.

Updating the summary to show in the 4.6 regression list.


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

* [Bug tree-optimization/47365] [4.5/4.6 Regression] wrong code with -O -ftree-pre
  2011-01-19 23:12 [Bug tree-optimization/47365] New: [4.5 Regression] wrong code with -O -ftree-pre zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2011-01-21  4:17 ` [Bug tree-optimization/47365] [4.5/4.6 " zsojka at seznam dot cz
@ 2011-01-21 14:08 ` rguenth at gcc dot gnu.org
  2011-01-21 14:14 ` rguenth at gcc dot gnu.org
  2011-01-21 14:22 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-01-21 14:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-21 14:02:45 UTC ---
Author: rguenth
Date: Fri Jan 21 14:02:41 2011
New Revision: 169089

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169089
Log:
2011-01-21  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/47365
    * tree-ssa-sccvn.h (vn_lookup_kind): Declare.
    (vn_reference_lookup_pieces): Adjust.
    (vn_reference_lookup): Likewise.
    * tree-ssa-sccvn.c (vn_walk_kind): New static global.
    (vn_reference_lookup_3): Only look through kills if in
    VN_WALKREWRITE mode.
    (vn_reference_lookup_pieces): Adjust.
    (vn_reference_lookup): Likewise.
    (visit_reference_op_load): Likewise.
    (visit_reference_op_store): Likewise.
    * tree-ssa-pre.c (phi_translate_1): Use VN_WALK mode.
    (compute_avail): Likewise.
    (eliminate): Likewise.

    * gcc.dg/torture/pr47365.c: New testcase.
    * gcc.dg/tree-ssa/pr47392.c: Likewise.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr47365.c
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr47392.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-pre.c
    trunk/gcc/tree-ssa-sccvn.c
    trunk/gcc/tree-ssa-sccvn.h


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

* [Bug tree-optimization/47365] [4.5/4.6 Regression] wrong code with -O -ftree-pre
  2011-01-19 23:12 [Bug tree-optimization/47365] New: [4.5 Regression] wrong code with -O -ftree-pre zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2011-01-21 14:08 ` rguenth at gcc dot gnu.org
@ 2011-01-21 14:14 ` rguenth at gcc dot gnu.org
  2011-01-21 14:22 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-01-21 14:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-21 14:05:03 UTC ---
Author: rguenth
Date: Fri Jan 21 14:05:00 2011
New Revision: 169090

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=169090
Log:
2011-01-21  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/47365
    * tree-ssa-sccvn.h (vn_lookup_kind): Declare.
    (vn_reference_lookup_pieces): Adjust.
    (vn_reference_lookup): Likewise.
    * tree-ssa-sccvn.c (vn_walk_kind): New static global.
    (vn_reference_lookup_3): Only look through kills if in
    VN_WALKREWRITE mode.
    (vn_reference_lookup_pieces): Adjust.
    (vn_reference_lookup): Likewise.
    (visit_reference_op_load): Likewise.
    (visit_reference_op_store): Likewise.
    * tree-ssa-pre.c (phi_translate_1): Use VN_WALK mode.
    (compute_avail): Likewise.
    (eliminate): Likewise.

    * gcc.dg/torture/pr47365.c: New testcase.
    * gcc.dg/tree-ssa/pr47392.c: Likewise.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/torture/pr47365.c
    branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/tree-ssa/pr47392.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_5-branch/gcc/tree-ssa-pre.c
    branches/gcc-4_5-branch/gcc/tree-ssa-sccvn.c
    branches/gcc-4_5-branch/gcc/tree-ssa-sccvn.h


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

* [Bug tree-optimization/47365] [4.5/4.6 Regression] wrong code with -O -ftree-pre
  2011-01-19 23:12 [Bug tree-optimization/47365] New: [4.5 Regression] wrong code with -O -ftree-pre zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2011-01-21 14:14 ` rguenth at gcc dot gnu.org
@ 2011-01-21 14:22 ` rguenth at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-01-21 14:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #6 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-01-21 14:06:55 UTC ---
Fixed.


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

end of thread, other threads:[~2011-01-21 14:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-19 23:12 [Bug tree-optimization/47365] New: [4.5 Regression] wrong code with -O -ftree-pre zsojka at seznam dot cz
2011-01-20 10:55 ` [Bug tree-optimization/47365] " rguenth at gcc dot gnu.org
2011-01-20 12:21 ` rguenth at gcc dot gnu.org
2011-01-21  4:17 ` [Bug tree-optimization/47365] [4.5/4.6 " zsojka at seznam dot cz
2011-01-21 14:08 ` rguenth at gcc dot gnu.org
2011-01-21 14:14 ` rguenth at gcc dot gnu.org
2011-01-21 14:22 ` 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).