This is an archive of the discontinued LLVM Phabricator instance.

[flang] Retain the sign of the argument for the result of fraction(0)
ClosedPublic

Authored by vdonaldson on May 25 2023, 10:19 AM.

Details

Reviewers
klausler
Summary

The f18 clause 16.9.80 description of the FRACTION(X) intrinsic states:

Result Value. The result has the value ....
If X has the value zero, the result is zero.
If X is an IEEE NaN, the result is that NaN.
If X is an IEEE infinity, the result is an IEEE NaN.

This clause does not specify whether fraction(-0.0) should be -0.0 or +0.0.
However, a folded result and a runtime result should be consistent, and
returning -0.0 is more in line with the result for fraction(NaN).

For this test:

print '(2f6.1)', 0.0, fraction(0.0)
call f(0.0)
print '(2f6.1)', -0.0, fraction(-0.0)
call f(-0.0)
end


subroutine f(x)
  print '(2f6.1)', x, fraction(x)
end

Current output is:

 0.0   0.0
 0.0   0.0
-0.0  -0.0
-0.0   0.0

Change that to:

 0.0   0.0
 0.0   0.0
-0.0  -0.0
-0.0  -0.0

Diff Detail

Event Timeline

vdonaldson created this revision.May 25 2023, 10:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 10:19 AM
vdonaldson requested review of this revision.May 25 2023, 10:19 AM
vdonaldson added a reviewer: klausler.
klausler accepted this revision.May 26 2023, 6:59 AM
This revision is now accepted and ready to land.May 26 2023, 6:59 AM