Skip to content

Commit

Permalink
Merge pull request #4394 from yebblies/issue13485
Browse files Browse the repository at this point in the history
Issue 13485 - FP wrong-code with -O
  • Loading branch information
WalterBright committed Feb 14, 2015
2 parents c438742 + 5b10f22 commit 527b3cf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/backend/glocal.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ STATIC void local_exp(elem *e,int goal)
if (em->Eoper == op &&
em->E1->EV.sp.Vsym == s &&
tysize(em->Ety) == tysize(e1->Ety) &&
!tyfloating(em->Ety) &&
em->E1->EV.sp.Voffset == e1->EV.sp.Voffset &&
!el_sideeffect(em->E2)
)
Expand Down
17 changes: 17 additions & 0 deletions test/runnable/mars1.d
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,22 @@ void test13190()

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

double foo13485(double c, double d)
{
// This must not be optimized to c += (d + d)
c += d;
c += d;
return c;
}

void test13485()
{
enum double d = 0X1P+1023;
assert(foo13485(-d, d) == d);
}

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

void test12833a(int a)
{
long x = cast(long)a;
Expand Down Expand Up @@ -1294,6 +1310,7 @@ int main()
testshrshl();
test13383();
test13190();
test13485();
test10639();
test10715();
test10678();
Expand Down

0 comments on commit 527b3cf

Please sign in to comment.