This is an archive of the discontinued LLVM Phabricator instance.

[ARM][LowOverheadLoops] Iteration count IT blocks
ClosedPublic

Authored by samparker on Feb 21 2020, 10:47 AM.

Details

Summary

Change the way that we remove the redundant iteration count code in the presence of IT blocks. collectLocalKilledOperands has been introduced to scan an instructions operands, collecting the killed instructions and then visiting them too. This is used to delete the code in the preheader which calculates the iteration count. We also track any IT blocks within the preheader and, if we remove all the instructions from the IT block, we also remove the IT instruction. isSafeToRemove is used to remove any redundant uses of the iteration count within the loop body.

Diff Detail

Event Timeline

samparker created this revision.Feb 21 2020, 10:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 21 2020, 10:47 AM

Sorry, just double-checking and asking the usual testing question: have we covered all cases for IT-blocks? I see cases when all instructions are dead and removed, I see cases where the instruction can't be removed, but do we have a test where one can be removed, and another not? Is there an existing test checking that?

llvm/lib/CodeGen/ReachingDefAnalysis.cpp
489

really minor nit: don't need the comparison, but can just return size and let the implicit conversion from int to bool do its work.

llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
903

nit: I think clang-format would suggest MachineInstr *

one more nit: would probably be good to add the [RDA] tag to the subject as some new functionally is added there too.

do we have a test where one can be removed, and another not? Is there an existing test checking that?

The it-block-random test does, it just removes the middle instruction from the block.

do we have a test where one can be removed, and another not? Is there an existing test checking that?

The it-block-random test does, it just removes the middle instruction from the block.

Ah yes, cheers.

LGTM, with one formatting nit that be fixed before committing.

After thinking about your question some more, I realised that in that case, we'd also have to modify the IT block mask and I don't think there's an really easy way of doing that... so I made a change to not remove any of the killed instructions in the case where we have a modified, not dead, IT block.

This revision was not accepted when it landed; it landed in state Needs Review.Feb 24 2020, 5:55 AM
This revision was automatically updated to reflect the committed changes.