struct C;
struct B { struct C *b; };
struct C { void (*baz) (struct B *, void *, int); };
typedef union { int f; void *e; } D;
struct E { struct B *e; };
struct A { struct E *a1; D *a2; D *a3; };
void
foo (long *x, long y)
{
*(long long *) x = y;
}
extern long fn1 (D);
extern void fn2 (void);
void
_bar (struct A *x)
{
register int a asm ("esi");
register D *volatile b asm ("edi");
register int c asm ("ebx");
void *d;
asm volatile ("" : "=r" (a), "=r" (b), "=r" (c) : : "memory");
if ((d = b[-2].e) != 0 && b [-2].e < d)
{
foo (&(((long *) d) + 1) [b[0].f], fn1 (b[-1]));
x->a2 = (D *) c;
x->a3 = b;
fn2 ();
}
x->a1->e->b->baz (x->a1->e, (void *) (long) a, 1);
}
Wonder why RA doesn't try to force the memory address into register, that would free up one register from the 4 otherwise needed (2 for the address, 2 for DImode value being stored into the memory).
Reduced testcase:
/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
/* { dg-options "-O2 -fno-gcse" } */
struct C;
struct B { struct C *b; };
struct C { void (*baz) (struct B *, void *, int); };
typedef union { int f; void *e; } D;
struct E { struct B *e; };
struct A { struct E *a1; D *a2; D *a3; };
void
foo (long *x, long y)
{
*(long long *) x = y;
}
extern long fn1 (D);
extern void fn2 (void);
void
_bar (struct A *x)
{
register int a asm ("esi");
register D *volatile b asm ("edi");
register int c asm ("ebx");
void *d;
asm volatile ("" : "=r" (a), "=r" (b), "=r" (c) : : "memory");
if ((d = b[-2].e) != 0 && b [-2].e < d)
{
foo (&(((long *) d) + 1) [b[0].f], fn1 (b[-1]));
x->a2 = (D *) c;
x->a3 = b;
fn2 ();
}
x->a1->e->b->baz (x->a1->e, (void *) (long) a, 1);
}
Wonder why RA doesn't try to force the memory address into register, that would free up one register from the 4 otherwise needed (2 for the address, 2 for DImode value being stored into the memory).