Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bugzilla Issue 24819 - Optimizer changes result of float calculat… #17028

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions compiler/src/dmd/backend/cgelem.d
Original file line number Diff line number Diff line change
Expand Up @@ -3888,6 +3888,10 @@
// If floating point, replace (x = -y) with (x = y ^ signbit)
if (op2 == OPneg && (tyreal(e2.Ety) || tyimaginary(e2.Ety)) &&
(e2.E1.Eoper == OPvar || e2.E1.Eoper == OPind) &&
/* Turned off for x87 because of https://issues.dlang.org/show_bug.cgi?id=24819
* and this is unnecessary anyway because of the FCHS x87 instruction
*/
!config.inline8087 &&

Check warning on line 3894 in compiler/src/dmd/backend/cgelem.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/cgelem.d#L3894

Added line #L3894 was not covered by tests
/* Turned off for XMM registers because they don't play well with
* int registers.
*/
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/backend/debugprint.d
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@
@trusted
void WRfunc(const char* msg, Symbol* sfunc, block* startblock)
{
printf("............%s...%s().............\n", msg, sfunc.Sident.ptr);
printf("............%s...%s()\n", msg, sfunc.Sident.ptr);

Check warning on line 513 in compiler/src/dmd/backend/debugprint.d

View check run for this annotation

Codecov / codecov/patch

compiler/src/dmd/backend/debugprint.d#L513

Added line #L513 was not covered by tests
numberBlocks(startblock);
for (block *b = startblock; b; b = b.Bnext)
WRblock(b);
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dmd/backend/dout.d
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ private void writefunc2(Symbol *sfunc)
{
func_t *f = sfunc.Sfunc;

//printf("writefunc(%s)\n",sfunc.Sident.ptr);
debugb && printf("=========== writefunc %s ==================\n",sfunc.Sident.ptr);
//symbol_print(sfunc);
debug debugy && printf("writefunc(%s)\n",sfunc.Sident.ptr);

Expand Down
18 changes: 18 additions & 0 deletions compiler/test/runnable/test24819.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import core.stdc.stdio;

pragma(inline, true)
double sqrt(double x)
{
static import core.math;
return core.math.sqrt(x);
}

int main()
{
double q = -5.0;
double r = q + 1.0;
double result = sqrt(-r);
//printf("%f\n", result);
assert(result == 2);
return 0;
}
Loading