This is an archive of the discontinued LLVM Phabricator instance.

[flang] Control SUM simplification with a pass option.
ClosedPublic

Authored by vzakhari on Aug 10 2022, 7:47 PM.

Details

Summary

The current code may not always work correctly, e.g.:
https://github.com/llvm/llvm-project/issues/57072

I added 'enable-experimental' pass option so that SUM simplification
may be enabled in LIT tests, but it is not enabled when the pass
is added to the passes pipeline.

Diff Detail

Event Timeline

vzakhari created this revision.Aug 10 2022, 7:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 7:47 PM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
vzakhari requested review of this revision.Aug 10 2022, 7:47 PM

As the fix for the bug mentioned is relatively simple, I'd suggest we fix the bug instead of introducing this sort of workaround.

Besides my comment in https://reviews.llvm.org/D131671#inline-1267048 I have another concern about the current SUM inlining. The current Fortran runtime implementation uses Kahan summation for the reduction, so I think we should have some control for SUM inlining to do the same. Otherwise, I am afraid after enabling this pass in the driver we may get accuracy issues for tests that pass with the current Fortran runtime.

I think it is still worth making SUM inlining experimental at this point.

Leporacanthicus accepted this revision.Aug 16 2022, 1:04 PM

LGTM. I do expect this to be short-lived [or at least for the SUM operations!]

This revision is now accepted and ready to land.Aug 16 2022, 1:04 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 17 2022, 1:39 PM