Skip to content

Commit

Permalink
Merge pull request #3803 from yebblies/issue13190
Browse files Browse the repository at this point in the history
[DDMD] Issue 13190 - Optimizer breaks comparison with zero
  • Loading branch information
WalterBright committed Jul 24, 2014
2 parents a85f5d7 + e73d4dd commit 9ceed60
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/backend/cod2.c
Expand Up @@ -2822,6 +2822,7 @@ code *cdind(elem *e,regm_t *pretregs)
gen2(ce,0xD1,modregrm(3,4,reg)); /* SHL reg,1 */
L4: cs.Iop = 0x0B;
getlvalue_lsw(&cs);
cs.Iflags |= CFpsw;
gen(ce,&cs); /* OR reg,lsw */
}
else if (!I32 && sz == 8)
Expand Down
31 changes: 31 additions & 0 deletions test/runnable/mars1.d
Expand Up @@ -1088,6 +1088,36 @@ int bug8525(int[] devt)

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

void func13190(int) {}

struct Struct13190
{
ulong a;
uint b;
};

__gshared Struct13190* table13190 =
[
Struct13190(1, 1),
Struct13190(0, 2)
];

void test13190()
{
for (int i = 0; table13190[i].a; i++)
{
ulong tbl = table13190[i].a;
func13190(i);
if (1 + tbl)
{
if (tbl == 0x80000)
return;
}
}
}

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

void test12833a(int a)
{
long x = cast(long)a;
Expand Down Expand Up @@ -1165,6 +1195,7 @@ int main()
testandand();
testor_combine();
testshrshl();
test13190();
test10639();
test10715();
test10678();
Expand Down

0 comments on commit 9ceed60

Please sign in to comment.