Skip to content

Commit

Permalink
convert register pair move to two single register moves
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Aug 20, 2015
1 parent 3cd472b commit 8ad21b5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 3 deletions.
25 changes: 25 additions & 0 deletions src/backend/cgelem.c
Expand Up @@ -3527,6 +3527,8 @@ STATIC elem * eleq(elem *e, goal_t goal)
)
{
tym_t ty = (REGSIZE == 8) ? TYllong : TYint;
if (tyfloating(e1->Ety) && REGSIZE >= 4)
ty = (REGSIZE == 8) ? TYdouble : TYfloat;
ty |= e1->Ety & ~mTYbasic;
e2->Ety = ty;
e->Ety = ty;
Expand All @@ -3552,6 +3554,29 @@ STATIC elem * eleq(elem *e, goal_t goal)
e2->Eoper = OPcomma;
return optelem(e2,goal);
}

// Replace (a=b) with (a1=b1),(a2=b2)
if (tysize(e1->Ety) == 2 * REGSIZE &&
e1->Eoper == OPvar &&
e2->Eoper == OPvar &&
goal == GOALnone
)
{
tym_t ty = (REGSIZE == 8) ? TYllong : TYint;
if (tyfloating(e1->Ety) && REGSIZE >= 4)
ty = (REGSIZE == 8) ? TYdouble : TYfloat;
ty |= e1->Ety & ~mTYbasic;
e2->Ety = ty;
e->Ety = ty;
e1->Ety = ty;

elem *eb = el_copytree(e);
eb->E1->EV.sp.Voffset += REGSIZE;
eb->E2->EV.sp.Voffset += REGSIZE;

e = el_bin(OPcomma,ty,e,eb);
return optelem(e,goal);
}
}

if (e1->Eoper == OPcomma)
Expand Down
6 changes: 3 additions & 3 deletions src/backend/cod1.c
Expand Up @@ -4204,11 +4204,11 @@ code *loaddata(elem *e,regm_t *pretregs)
// See if we can use register that parameter was passed in
if (regcon.params &&
(e->EV.sp.Vsym->Sclass == SCfastpar || e->EV.sp.Vsym->Sclass == SCshadowreg) &&
regcon.params & mask[e->EV.sp.Vsym->Spreg] &&
!(e->Eoper == OPvar && e->EV.sp.Voffset > 0) && // Must be at the base of that variable
(regcon.params & mask[e->EV.sp.Vsym->Spreg] && e->EV.sp.Voffset == 0 ||
regcon.params & mask[e->EV.sp.Vsym->Spreg2] && e->EV.sp.Voffset == REGSIZE) &&
sz <= REGSIZE) // make sure no 'paint' to a larger size happened
{
reg = e->EV.sp.Vsym->Spreg;
reg = e->EV.sp.Voffset ? e->EV.sp.Vsym->Spreg2 : e->EV.sp.Vsym->Spreg;
forregs = mask[reg];
#ifdef DEBUG
if (debugr)
Expand Down
13 changes: 13 additions & 0 deletions test/runnable/mars1.d
Expand Up @@ -1344,6 +1344,18 @@ void test14829()
}


////////////////////////////////////////////////////////////////////////

void test2()
{
void test(cdouble v)
{
auto x2 = cdouble(v);
assert(x2 == v);
}
test(1.2+3.4i);
}

////////////////////////////////////////////////////////////////////////

int main()
Expand Down Expand Up @@ -1389,6 +1401,7 @@ int main()
test13784();
test14220();
test14829();
test2();
printf("Success\n");
return 0;
}

0 comments on commit 8ad21b5

Please sign in to comment.