Skip to content

Commit

Permalink
Merge pull request #3776 from yebblies/issue12833
Browse files Browse the repository at this point in the history
Issue 12833 - switch statement does not work properly when -inline used
  • Loading branch information
WalterBright committed Jul 17, 2014
2 parents 63a14e6 + 82da99d commit e701790
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/backend/cod4.c
Expand Up @@ -2902,10 +2902,10 @@ code *cdshtlng(elem *e,regm_t *pretregs)
if (op == OPu16_32 && c1)
{
code *cx = code_last(c1);
if (cx->Iop == 0x81 && (cx->Irm & modregrm(3,7,0)) == modregrm(3,4,0))
if (cx->Iop == 0x81 && (cx->Irm & modregrm(3,7,0)) == modregrm(3,4,0) &&
mask[cx->Irm & 7] == retregs)
{
// Convert AND of a word to AND of a dword, zeroing upper word
retregs = mask[cx->Irm & 7];
if (cx->Irex & REX_B)
retregs = mask[8 | (cx->Irm & 7)];
cx->Iflags &= ~CFopsize;
Expand Down
24 changes: 24 additions & 0 deletions test/runnable/mars1.d
Expand Up @@ -1086,6 +1086,29 @@ int bug8525(int[] devt)
return devt[$ - 1];
}

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

void test12833a(int a)
{
long x = cast(long)a;

switch (cast(int)(cast(ushort)(x >> 16 & 65535L)))
{
case 1:
{
break;
}
default:
{
assert(0);
}
}
}

void test12833()
{
test12833a(0x1_0000);
}

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

Expand Down Expand Up @@ -1119,6 +1142,7 @@ int main()
test10715();
test10678();
test7565();
test12833();
printf("Success\n");
return 0;
}

0 comments on commit e701790

Please sign in to comment.