This is an archive of the discontinued LLVM Phabricator instance.

Add FuncPass Implementation for non-trivial LoopUnswitching
AbandonedPublic

Authored by drcut on Jun 10 2022, 3:52 PM.

Details

Summary

Implement non-trivial LoopUnswitching with FunctionPass. Since non-trivial LoopUnswitching may rely on Function Analysis, it's better be implemented based on FuncPass.

Diff Detail

Event Timeline

drcut created this revision.Jun 10 2022, 3:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 3:52 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
drcut requested review of this revision.Jun 10 2022, 3:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2022, 3:52 PM

It seems the loop pass in the new PM already has an option to perform non-trivial unswitching, the purpose of this pass is not clear. Doesn't the core function unswitchLoop() use the same analyses in both cases? Does the function pass use an analysis that is not in the LoopStandardAnalysisResults?

llvm/lib/Passes/PassRegistry.def
362

Is there a better way to name this option? The function pass feels like an implementation detail. Is there something else that conveys the significance?

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
3219–3226

The body of this pass closely resembles the loop pass, but the state is too mixed up to refactor. But at least this part with the string literals deserves to be commoned out.

this was done for https://discourse.llvm.org/t/rfc-re-implement-non-trivial-simpleloopunswitch-with-functionpass/62937, which we're no longer pursuing
we should probably abandon this patch

drcut abandoned this revision.Aug 8 2022, 11:05 AM

This patch implements SimpleLoopUnswitch using FuncPass, which can be used to replace the LoopPass implementation currently used in the optimization pipeline.
This patch has been verified and can be re-opened once we find using FuncPass for SLU is necessary/beneficial.