This is an archive of the discontinued LLVM Phabricator instance.

[LoopFuse] Ensure inner loops are in loop simplified form under new PM
ClosedPublic

Authored by Narutoworld on Nov 8 2022, 2:33 PM.

Details

Summary

This patch tries to fix issue.

LoopInfo doesn't give all loops in a loop nest, it gives top level loops only. While isLoopSimplifyForm() only checkes for the outter most loop of a loop nest. As a result, inner loops that are not in simplied form can not be simplified with the original code.

This patch tries to run simplifyLoop() on loop nests anyway and let it simplify each loop in a loop nest recursively.

Diff Detail

Event Timeline

Narutoworld created this revision.Nov 8 2022, 2:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 8 2022, 2:33 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
Narutoworld requested review of this revision.Nov 8 2022, 2:33 PM
Narutoworld retitled this revision from [LoopFuse] fix issue 58775 to [LoopFuse] Ensure inner loops are in loop simplified form under new PM.Nov 8 2022, 3:11 PM
Narutoworld edited the summary of this revision. (Show Details)
Narutoworld added reviewers: bjope, aeubanks, uabelho.
Narutoworld edited the summary of this revision. (Show Details)

testcase added

I've verified that this solves the original problem I saw.
The fix looks reasonable to me but I'd like someone who knows this code to accept it.

aeubanks accepted this revision.Nov 10 2022, 9:19 AM

description nit: LI doesn't give you loop nests, it gives you top level loops

lg with test and description fixes

llvm/test/Transforms/LoopFusion/ensure_loop_simplify_form.ll
37

there's already a RUN at the top

66

this is UB, can you replace these with a constant like true?

This revision is now accepted and ready to land.Nov 10 2022, 9:19 AM
Narutoworld edited the summary of this revision. (Show Details)Nov 11 2022, 8:07 AM
Narutoworld marked 2 inline comments as done.

update testcase based on comments

resolve comments

Narutoworld edited the summary of this revision. (Show Details)Nov 11 2022, 12:54 PM
This revision was landed with ongoing or failed builds.Nov 11 2022, 12:58 PM
This revision was automatically updated to reflect the committed changes.