Skip to content

Commit

Permalink
gsroa: allow anything that fits in a slice to be a slice
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jan 21, 2019
1 parent 0a8fdf2 commit d3955f7
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/dmd/backend/gsroa.d
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ extern (D) private void sliceStructs_Gather(const symtab_t* symtab, SymInfo[] si
ty = TYnptr;
}
sia[si].accessSlice = true;
sia[si].ty[n] = tybasic(e.Ety);
if (sz == SLICESIZE)
sia[si].ty[n] = tybasic(e.Ety);
}
else
{
Expand Down Expand Up @@ -214,7 +215,7 @@ extern (D) private void sliceStructs_Replace(symtab_t* symtab, const SymInfo[] s
else // the nth slice
{
e.EV.Vsym = symtab.tab[sia[si].si0 + n];
e.EV.Voffset = 0;
e.EV.Voffset -= n * SLICESIZE;
//printf("replaced with:\n");
//elem_print(e);
}
Expand Down Expand Up @@ -409,13 +410,17 @@ enum NOTSLICE = -1;
int nthSlice(const(elem)* e)
{
const sz = tysize(e.Ety);
if (sz == SLICESIZE)
{
if (e.EV.Voffset == 0)
return 0;
if (e.EV.Voffset == SLICESIZE)
return 1;
}
const sliceSize = SLICESIZE;

/* See if e fits in a slice
*/
const lwr = e.EV.Voffset;
const upr = lwr + sz;
if (0 <= lwr && upr <= sliceSize)
return 0;
if (sliceSize <= lwr && upr <= sliceSize * 2)
return 1;

return NOTSLICE;
}

Expand Down

0 comments on commit d3955f7

Please sign in to comment.