This is an archive of the discontinued LLVM Phabricator instance.

Fix loop unrolling initialization in the new pass manager
AcceptedPublic

Authored by echristo on Oct 4 2019, 10:27 PM.

Details

Summary

In the new pass manager use PTO.LoopUnrolling to determine when and how
we will unroll loops. Also comment a few occasions where we need to
know whether or not we're forcing the unwinder or not.

Testcase is in clang because it's controlling how the loop optimizer
is being set up and there's no other way to trigger the behavior.

Diff Detail

Repository
rL LLVM

Event Timeline

echristo created this revision.Oct 4 2019, 10:27 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 4 2019, 10:27 PM
chandlerc accepted this revision.Oct 5 2019, 11:01 PM
chandlerc added a reviewer: asbirlea.

Adding Alina so she is aware of the change and can comment if she spots anything I'm missing...

I think this is fine to go in as-is to fix the immediate issues. It'd be good to find a way to write an LLVM test for the unrolling functionality change and the unroll-and-jam change I comment on below. But I'm OK w/ those landing in follow-up changes, no need to hold up the simple fix here.

clang/test/Misc/loop-opt-setup.c
2

I'd use -fno-experimental-new-pass-manager here so we don't lose coverage when flipping defaults.

llvm/lib/Passes/PassBuilder.cpp
953

We don't have a test for this sadly.... Not sure the best way to add one.

This revision is now accepted and ready to land.Oct 5 2019, 11:01 PM

Maybe elaborate in the patch description what determine when and how we will unroll loops. means?
e.g.:
"The default before and after this patch is for LoopUnroll to be enabled, and for it to use a cost model to determine whether to unroll the loop (OnlyWhenForced = false). Before this patch, disabling loop unroll would not run the LoopUnroll pass. After this patch, the LoopUnroll pass is being run, but it restricts unrolling to only the loops marked by a pragma (OnlyWhenForced = true).
In addition, this patch disables the UnrollAndJam pass when disabling unrolling."

Otherwise LGTM.