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 committed Nov 26, 2024
1 parent 4c645bb commit 45adf2e
Show file tree
Hide file tree
Showing 2 changed files with 44 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
43 changes: 43 additions & 0 deletions compiler/test/runnable/test24884.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
REQUIRED_ARGS: -inline
*/

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

void vecdiff(ref double[4] a, ref double[4] b, ref double[4] result)
{
result[0] = a[0] - b[0];
result[1] = a[1] - b[1];
result[2] = a[2] - b[2];
result[3] = a[3];
}

pragma(inline, false)
double norm(ref double[4] a) => 0;

pragma(inline, false)
void outerproduct(ref double[4] a, ref double[4] b, ref double[4] c) {}

pragma(inline, false)
double innerproduct(ref double[4] a, ref double[4] b) => 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;
vecdiff(point1, point2, v1);
vecdiff(point2, point3, v2);

outerproduct(v1, v2, abcd);
if (norm(abcd) > 0.0)
{
abcd[0] = innerproduct(abcd, point1);
}
}

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

0 comments on commit 45adf2e

Please sign in to comment.