Skip to content

Commit

Permalink
Fix bugzilla 24884 - backend generates wrong 32-bit code after inlini…
Browse files Browse the repository at this point in the history
…ng math with double[4]
  • Loading branch information
Dennis Korpel authored and dlang-bot committed Nov 29, 2024
1 parent a3abf11 commit 8b1eb80
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/src/dmd/backend/x86/cod2.d
Original file line number Diff line number Diff line change
Expand Up @@ -4149,6 +4149,7 @@ void cdmemset(ref CGstate cg, ref CodeBuilder cdb,elem *e,regm_t *pretregs)
if (valueIsConst)
{
regwithvalue(cdb, mAX, value, I64?64:0);
getregs(cdb, mAX);
freenode(evalue);
}
else
Expand Down
34 changes: 34 additions & 0 deletions compiler/test/runnable/test24884.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
REQUIRED_ARGS: -inline
*/

// https://issues.dlang.org/show_bug.cgi?id=24884

pragma(inline, false)
bool norm(int a) => 0;

pragma(inline, false)
void inlinebug(ref double[4] point1, ref double[4] point2, ref double[4] point3, ref double[4] abcd)
{
double[4] v1 = 0.0;
double[4] v2 = 0.0;

v1[0] = point1[0] - point2[0];
v1[1] = point1[1] - point2[1];
v1[2] = point1[2] - point2[2];
v1[3] = point1[3];
v2[0] = point2[0] - point3[0];
v2[1] = point2[1] - point3[1];
v2[2] = point2[2] - point3[2];

int p = cast(int) &abcd;
int q = cast(int) &point1;
abcd[0] = norm(7) + p;
abcd[1] = q + p;
}

extern(C) void main()
{
double[4] a = 0.0;
inlinebug(a, a, a, a);
}

0 comments on commit 8b1eb80

Please sign in to comment.