This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch i386]: Expand sibling-tail-calls via accumulator register
- From: Kai Tietz <ktietz70 at googlemail dot com>
- To: Bernd Edlinger <bernd dot edlinger at hotmail dot de>
- Cc: Kai Tietz <ktietz at redhat dot com>, "H.J. Lu" <hjl dot tools at gmail dot com>, Richard Henderson <rth at redhat dot com>, Jeff Law <law at redhat dot com>, Jakub Jelinek <jakub at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 31 May 2014 12:15:40 +0200
- Subject: Re: [patch i386]: Expand sibling-tail-calls via accumulator register
- Authentication-results: sourceware.org; auth=none
- References: <DUB118-W201EA644C6D3AB8CB15C4FE4270 at phx dot gbl> <CAEwic4b5WF4m-vPWPAEjh=tF9VA3zDXGEx1_QQrHF8892j+u4A at mail dot gmail dot com>
That patch won't help here. My tests showing here a different
problem. For -O2 or above this issue happens.
For -O2 the following code will be generated.
movl 28(%esp), %eax
testl %eax, %eax
je L16
movl %ebp, 64(%esp)
addl $44, %esp
popl %ebx
popl %esi
popl %edi
popl %ebp
jmp *28(%esp)
Question here is why it tries to use memory-address here instead of
simply using eax-register, which is already loaded.
A small testcase for that is:
typedef void *ira_loop_tree_node_t;
#define NULL 0
extern int end (int);
extern int doo (int);
void
ira_traverse_loop_tree (bool bb_p, ira_loop_tree_node_t loop_node,
void (*preorder_func) (ira_loop_tree_node_t),
void (*postorder_func) (ira_loop_tree_node_t))
{
int l, r = 0x1, h = 0, j = 0;
if (preorder_func != NULL)
(*preorder_func) (loop_node);
if (bb_p)
{
for (l = 0; l < end (l); l++)
{
r += doo (l);
h += (l + 1) * 3;
h %= (l + 1);
r -= doo (h);
j += (l + 1) * 7;
j %= (l + 1);
r += doo (j);
}
}
if (postorder_func != NULL)
(*postorder_func) (loop_node);
}