This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Implement branch analysis
ClosedPublic

Authored by wangleiat on Aug 6 2022, 1:41 AM.

Details

Summary

This allows a number of optimisation passes to work.
E.g. BranchFolding and MachineBlockPlacement.

Diff Detail

Event Timeline

wangleiat created this revision.Aug 6 2022, 1:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2022, 1:41 AM
wangleiat requested review of this revision.Aug 6 2022, 1:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 6 2022, 1:41 AM
xen0n accepted this revision.Aug 6 2022, 2:27 AM
This revision is now accepted and ready to land.Aug 6 2022, 2:27 AM

Just passed by, you can ignore my comments.

llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
168

How is this possible to have instructions after an unconditional terminator? I think it should be asserted that there are none.

179

This check seems superfluous, the code below will filter out this case.

216

This is impossible condition, because this function is only called if analyzeBranch returned success, and that returns success only if the last instruction was an (un-)conditional branch.

Just passed by, you can ignore my comments.

Thanks for your comments.

llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
168

Agree with you, but this situation really needs to be handled here. Because`insertBranch` will add an unconditional branch with BranchFolder pass.

179

Yes, I will remove it.

216

analyzeBranch will return success when the block has no branches (nothing to be removed).

isBranch() condition maybe ok?

if (!I->getDesc().isBranch())
    return 0;
wangleiat updated this revision to Diff 450712.Aug 7 2022, 11:22 PM

Address @barannikov88's comments.

SixWeining accepted this revision.Aug 8 2022, 10:53 PM
This revision was landed with ongoing or failed builds.Aug 8 2022, 11:03 PM
This revision was automatically updated to reflect the committed changes.