This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add -f[no-]associative-math and -mreassociate
ClosedPublic

Authored by tblah on Nov 3 2022, 4:27 AM.

Details

Summary

Only add the option processing and store the result. No attributes are added to FIR yet.

Clang only forwards -mreassociate

if (AssociativeMath && !SignedZeros && !TrappingMath)

Flang doesn't have -f[no-]trapping-math, so this part of the condition has been omitted. !TrappingMath is the default.

Diff Detail

Event Timeline

tblah created this revision.Nov 3 2022, 4:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2022, 4:27 AM
tblah requested review of this revision.Nov 3 2022, 4:27 AM
tblah edited the summary of this revision. (Show Details)Nov 3 2022, 4:27 AM
tblah updated this revision to Diff 472950.Nov 3 2022, 8:29 AM
This revision is now accepted and ready to land.Nov 3 2022, 10:46 AM
awarzynski accepted this revision.Nov 4 2022, 7:54 AM

LGTM, thanks!

This revision was automatically updated to reflect the committed changes.
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptNov 4 2022, 10:25 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Wouldn't it be good to have a RFC for all these options and what they will do in Flang instead of just adding them all? Or did I miss the RFC?

Wouldn't it be good to have a RFC for all these options and what they will do in Flang instead of just adding them all? Or did I miss the RFC?

+1

Wouldn't it be good to have a RFC for all these options and what they will do in Flang instead of just adding them all? Or did I miss the RFC?

+1

Fast Math attributes supported in LLVM IR are documented in https://llvm.org/docs/LangRef.html#fast-math-flags. This set of patches (details below) provides a way to set or unset each of these attributes.

While making policy decisions about these flags, like for ffp-contract, we have created an RFC (https://discourse.llvm.org/t/rfc-ffp-contract-default-value/66301). When adding umbrella flags like -ffast-math/-Ofast/-ffp-model/-funsafe-math-optimizations, we will submit RFCs.

Patch : Flag Name : LLVM IR Attribute
https://reviews.llvm.org/D137325 : f[no-]honor-nans : nnan
https://reviews.llvm.org/D137072 : f[no-]honor-infinities : ninf
https://reviews.llvm.org/D137328 : f[no-]signed-zeros : nsz
https://reviews.llvm.org/D137330 : f[no-]reciprocal-math : arcp
https://reviews.llvm.org/D136080 : ffp-contract option : contract
https://reviews.llvm.org/D137326 : f[no-]approx-func : afn
https://reviews.llvm.org/D137329 : f[no-]associative-math: reassoc

Wouldn't it be good to have a RFC for all these options and what they will do in Flang instead of just adding them all? Or did I miss the RFC?

+1

Fast Math attributes supported in LLVM IR are documented in https://llvm.org/docs/LangRef.html#fast-math-flags. This set of patches (details below) provides a way to set or unset each of these attributes.

While making policy decisions about these flags, like for ffp-contract, we have created an RFC (https://discourse.llvm.org/t/rfc-ffp-contract-default-value/66301). When adding umbrella flags like -ffast-math/-Ofast/-ffp-model/-funsafe-math-optimizations, we will submit RFCs.

Patch : Flag Name : LLVM IR Attribute
https://reviews.llvm.org/D137325 : f[no-]honor-nans : nnan
https://reviews.llvm.org/D137072 : f[no-]honor-infinities : ninf
https://reviews.llvm.org/D137328 : f[no-]signed-zeros : nsz
https://reviews.llvm.org/D137330 : f[no-]reciprocal-math : arcp
https://reviews.llvm.org/D136080 : ffp-contract option : contract
https://reviews.llvm.org/D137326 : f[no-]approx-func : afn
https://reviews.llvm.org/D137329 : f[no-]associative-math: reassoc

Thanks for this summary Kiran!