public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts
@ 2010-12-20 18:56 zsojka at seznam dot cz
  2010-12-20 19:20 ` [Bug rtl-optimization/47028] " zsojka at seznam dot cz
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: zsojka at seznam dot cz @ 2010-12-20 18:56 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c
                    FAIL with -foptimize-sibling-calls
                    -fno-forward-propagate -fno-tree-copy-prop
                    -fno-tree-dominator-opts
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: zsojka@seznam.cz
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu


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

Output:
$ gcc -O -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop
-fno-tree-dominator-opts pr47028.c
$ ./a.out 
Aborted

At the assembly level, fib() is reduced to "return 1;":
fib:
    mov    eax, 0    # add_acc.0,
    add    eax, 1    # tmp73,
    ret

it seems to first appear in the pr47028.c.179r.combine dump

Tested revision:
r168061 - fail
r165699 - fail
r161659 - OK
4.5 r168062 -OK


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

* [Bug rtl-optimization/47028] [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts
  2010-12-20 18:56 [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts zsojka at seznam dot cz
@ 2010-12-20 19:20 ` zsojka at seznam dot cz
  2010-12-27 19:06 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: zsojka at seznam dot cz @ 2010-12-20 19:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Zdenek Sojka <zsojka at seznam dot cz> 2010-12-20 19:20:12 UTC ---
Created attachment 22833
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22833
another testcase (reduced from gcc.dg/tree-ssa/tailrecursion-7.c)

I hope this is the same problem as the first testcase.

$ gcc -O -foptimize-sibling-calls -fno-tree-copy-prop -fno-tree-dominator-opts
pr47028-2.c
$ ./a.out 
Aborted
(it takes some time to run, the inner loop is done 2^32-1 times instead of n-1)

When the assembly is changed in the following way:
--- pr47028-2.s 2010-12-20 20:16:12.000000000 +0100
+++ pr47028-2-fixed.s   2010-12-20 20:16:26.000000000 +0100
@@ -41,7 +41,7 @@
 foo:
 .LFB0:
        .cfi_startproc
-       mov     edx, 0  # n,
+       mov     edx, edi        # n,
        mov     eax, 1  # mul_tmp.4,
        mov     esi, 0  # add_acc.1,
        test    edi, edi        # n

it works fine. edx is loaded by '0' instead of 'n'.


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

* [Bug rtl-optimization/47028] [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts
  2010-12-20 18:56 [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts zsojka at seznam dot cz
  2010-12-20 19:20 ` [Bug rtl-optimization/47028] " zsojka at seznam dot cz
@ 2010-12-27 19:06 ` jakub at gcc dot gnu.org
  2010-12-30 13:19 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-12-27 19:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

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


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

* [Bug rtl-optimization/47028] [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts
  2010-12-20 18:56 [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts zsojka at seznam dot cz
  2010-12-20 19:20 ` [Bug rtl-optimization/47028] " zsojka at seznam dot cz
  2010-12-27 19:06 ` jakub at gcc dot gnu.org
@ 2010-12-30 13:19 ` jakub at gcc dot gnu.org
  2010-12-30 14:44 ` hjl.tools at gmail dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-12-30 13:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-12-30 13:19:21 UTC ---
The problem is much earlier than that.
In *.expand we have:
;; Start of basic block ( 0) -> 2
;; Pred edge  ENTRY [100.0%]  (fallthru)
(note 12 6 9 2 [bb 2] NOTE_INSN_BASIC_BLOCK)

(insn 9 12 7 2 (set (reg/v:SI 70 [ n ])
        (reg/v:SI 72 [ n ])) pr47028.c:7 -1
     (nil))

(insn 7 9 8 2 (set (reg/v:SI 72 [ n ])
        (reg:SI 5 di [ n ])) pr47028.c:7 -1
     (nil))
where obviously insn 7 should be before insn 9, not the other way around.
The reason it is emitted that way is because in *.optimized we have:
<bb 2>:
  # n_13 = PHI <n_3(D)(0)>
and insn 9 is insert_partition_copy_on_edge'ed on the ENTRY_BLOCK_PTR -> bb 2
edge, which is before the argument setup.

So, either insertions on the single edge from ENTRY_BLOCK_PTR to the entry bb
should be committed after parm_birth_insn instead of the start of that bb, or
we need to ensure even if the user ridiculously turns off all optimization
passes that clean up degenerated PHIs they get cleaned up somewhere.  The PHI
here is created during tail recursion pass, but at that point it is not
degenerate PHI, it only becomes one during some cfg cleanup afterwards.


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

* [Bug rtl-optimization/47028] [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts
  2010-12-20 18:56 [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2010-12-30 13:19 ` jakub at gcc dot gnu.org
@ 2010-12-30 14:44 ` hjl.tools at gmail dot com
  2010-12-30 16:00 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2010-12-30 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2010.12.30 14:43:46
                 CC|                            |xinliangli at gmail dot com
     Ever Confirmed|0                           |1

--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> 2010-12-30 14:43:46 UTC ---
It is caused by revision 162585:

http://gcc.gnu.org/ml/gcc-cvs/2010-07/msg00939.html


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

* [Bug rtl-optimization/47028] [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts
  2010-12-20 18:56 [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2010-12-30 14:44 ` hjl.tools at gmail dot com
@ 2010-12-30 16:00 ` jakub at gcc dot gnu.org
  2010-12-30 18:57 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2010-12-30 16:00 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |jakub at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> 2010-12-30 16:00:16 UTC ---
Created attachment 22869
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22869
gcc46-pr47028.patch

Untested fix.


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

* [Bug rtl-optimization/47028] [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts
  2010-12-20 18:56 [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2010-12-30 16:00 ` jakub at gcc dot gnu.org
@ 2010-12-30 18:57 ` rguenth at gcc dot gnu.org
  2011-01-02 17:07 ` jakub at gcc dot gnu.org
  2011-01-02 17:24 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2010-12-30 18:57 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-12-30 18:57:10 UTC ---
(In reply to comment #4)
> Created attachment 22869 [details]
> gcc46-pr47028.patch
> 
> Untested fix.

While the patch looks reasonable I wonder why we can't get rid of degenerate
PHI nodes in cfgcleanup (I wondered so multiple times) - of course we
have to avoid destroying loop-closed SSA form.


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

* [Bug rtl-optimization/47028] [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts
  2010-12-20 18:56 [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2010-12-30 18:57 ` rguenth at gcc dot gnu.org
@ 2011-01-02 17:07 ` jakub at gcc dot gnu.org
  2011-01-02 17:24 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-02 17:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-02 17:07:18 UTC ---
Author: jakub
Date: Sun Jan  2 17:07:15 2011
New Revision: 168401

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=168401
Log:
    PR rtl-optimization/47028
    * cfgexpand.c (gimple_expand_cfg): Insert entry edge
    insertions after parm_birth_insn instead of at the beginning
    of first bb.

    * gcc.dg/pr47028.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr47028.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cfgexpand.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug rtl-optimization/47028] [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts
  2010-12-20 18:56 [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts zsojka at seznam dot cz
                   ` (6 preceding siblings ...)
  2011-01-02 17:07 ` jakub at gcc dot gnu.org
@ 2011-01-02 17:24 ` jakub at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-01-02 17:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-01-02 17:24:00 UTC ---
Fixed.


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

end of thread, other threads:[~2011-01-02 17:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-20 18:56 [Bug rtl-optimization/47028] New: [4.6 Regression] gcc.dg/tree-ssa/tailrecursion-[57].c FAIL with -foptimize-sibling-calls -fno-forward-propagate -fno-tree-copy-prop -fno-tree-dominator-opts zsojka at seznam dot cz
2010-12-20 19:20 ` [Bug rtl-optimization/47028] " zsojka at seznam dot cz
2010-12-27 19:06 ` jakub at gcc dot gnu.org
2010-12-30 13:19 ` jakub at gcc dot gnu.org
2010-12-30 14:44 ` hjl.tools at gmail dot com
2010-12-30 16:00 ` jakub at gcc dot gnu.org
2010-12-30 18:57 ` rguenth at gcc dot gnu.org
2011-01-02 17:07 ` jakub at gcc dot gnu.org
2011-01-02 17:24 ` 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).