This is an archive of the discontinued LLVM Phabricator instance.

[flang] Lower MOD to Fortran runtime call.
ClosedPublic

Authored by vzakhari on Aug 4 2022, 12:19 PM.

Details

Summary

This change removes dependency on pgmath mod, and also allows
Fortran runtime to issue a diagnostic message in case of zero
denominator.

Diff Detail

Event Timeline

vzakhari created this revision.Aug 4 2022, 12:19 PM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: mehdi_amini. · View Herald Transcript
vzakhari requested review of this revision.Aug 4 2022, 12:19 PM
jeanPerier accepted this revision.Aug 5 2022, 12:35 AM

Looks good to me

flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
311

Isn't it safe to upcast the arguments to use the ModReal4 version and to downcast the result in those cases ?

This revision is now accepted and ready to land.Aug 5 2022, 12:35 AM
klausler added inline comments.Aug 5 2022, 6:15 AM
flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
311

That's risky, since there would be an extra rounding, and MOD should be exact.

It's possible to check the whole range of 16-bit operand value pairs for safety.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2022, 12:57 PM