This is an archive of the discontinued LLVM Phabricator instance.

Add -f[no-]loop-versioning option
ClosedPublic

Authored by Leporacanthicus on Jan 9 2023, 10:27 AM.

Details

Summary

Add flags for loop-versioning pass enable/disable

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Leporacanthicus requested review of this revision.Jan 9 2023, 10:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 9 2023, 10:27 AM

Rebased and updated help-message

Also using different type of template for the option

Update for rebase.

Leporacanthicus retitled this revision from [WIP] Add -f[no-]loop-versioning option to Add -f[no-]loop-versioning option.Mar 3 2023, 2:39 AM
Leporacanthicus edited the summary of this revision. (Show Details)
tblah added a subscriber: tblah.Mar 6 2023, 10:06 AM

Please could you add tests for the flag forwarding logic in flang/tests/Driver/frontend-forwarding.f90. For example see https://reviews.llvm.org/rGd0d4b635786d510cd919cadbeb7e5e19983242cf

clang/lib/Driver/ToolChains/Flang.cpp
69

Does GFortran only enable this with -Ofast? I would have thought this would be an -On thing because it doesn't impact precision.

flang/include/flang/Frontend/CodeGenOptions.def
27

nit: comment

Updates based on review comments:

  • Add tests.
  • Enable on -O3

Also changed the name to match gfortran.

Leporacanthicus marked an inline comment as done.Mar 8 2023, 7:41 AM
Leporacanthicus added inline comments.
clang/lib/Driver/ToolChains/Flang.cpp
69

No, good point.

flang/include/flang/Frontend/CodeGenOptions.def
27

Darn, missed fixing this.

Leporacanthicus marked an inline comment as done.

Fix copied comment to reflect the new content.

tblah accepted this revision.Mar 9 2023, 3:28 AM

Looks good to me

This revision is now accepted and ready to land.Mar 9 2023, 3:28 AM

Rebase and fix conflicts

Mats, thanks for working on this! Just a few minor suggestions from me.

clang/lib/Driver/ToolChains/Flang.cpp
54

Could you add a short Docstring, pls? In particular, is the logic implemented by this method consistent with GFortran? Are there any external docs that could be referred to here?

55

Please rewrite this to use early exit, e.g.:

Arg *LoopVersionOption = Args.getLastArg(options::OPT_Ofast, options::OPT_O,
                             options::OPT_O4, options::OPT_floop_versioning,
                             options::OPT_fno_loop_versioning)
if !(LoopVersionOption)
  return false;

// The remaining logic HERE
68–69

Would you classify this as a code-gen option? Alongside -fstack-arrays and -flang-experimental-hlfir? It sound like we could introduce another hook here, adddCodeGenOptions?

flang/test/Driver/version-loops.f90
2 ↗(On Diff #511416)
5 ↗(On Diff #511416)

[nit] If you are using -###, then you can just skip -fsyntax-only (it doesn't really matter what "action" is requested from the frontend driver).

33–34 ↗(On Diff #511416)

Similar suggestion for other CHECK lines - this will make the test a bit more explicit about the expected output.

Leporacanthicus marked 3 inline comments as done.
  • Add new function to help clarify the purpose of the options being used.
  • Add descriptive comment to make function use clearer.
  • Update tests to make them a more explicit.
Leporacanthicus marked 2 inline comments as done.Apr 12 2023, 11:58 AM
awarzynski accepted this revision.Apr 12 2023, 12:41 PM

LGTM, thanks!

Remove unnecessary braces in if-statement.

This revision was landed with ongoing or failed builds.Apr 18 2023, 1:48 AM
This revision was automatically updated to reflect the committed changes.