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'.

Reply via email to