This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Improve detection of fallthough when aligning blocks
ClosedPublic

Authored by dmgreen on Aug 10 2021, 3:20 AM.

Details

Summary

We align non-fallthrough branches under Cortex-M at O3 to lead to fewer instruction fetches. This improves that for the block after a LE or LETP. These blocks will still have branches on until the LowOverheadLoops pass is run (as they are not handled by analyzeBranch, the branch is not removed until later), so canFallThrough will return false. These extra branches will eventually be removed, leaving a fallthrough, so treat them as such and don't add unnecessary alignments.

Diff Detail

Event Timeline

dmgreen created this revision.Aug 10 2021, 3:20 AM
dmgreen requested review of this revision.Aug 10 2021, 3:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2021, 3:20 AM
samtebbs added inline comments.Sep 1 2021, 9:12 AM
llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
360

If my understanding is correct then the fall-through branch at the end of MBB isn't removed until the LowOverheadLoops pass. Do we therefore need to check if LOL are enabled?

dmgreen added inline comments.Sep 6 2021, 7:50 AM
llvm/lib/Target/ARM/ARMConstantIslandPass.cpp
360

Hmm. I was considering that all non-lob cases would already have been cleared up, handled by analyzeBranch, but perhaps you are right and this should be checking more specifically.

dmgreen updated this revision to Diff 370927.Sep 6 2021, 8:15 AM

Check LOB instructions specifically.

samtebbs accepted this revision.Sep 21 2021, 9:23 AM

Apologies for taking a long time to get back to you on this! LGTM

This revision is now accepted and ready to land.Sep 21 2021, 9:23 AM
This revision was landed with ongoing or failed builds.Sep 27 2021, 3:21 AM
This revision was automatically updated to reflect the committed changes.