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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
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.
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.
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.