From 25cbfe680ef01db07e4ef44849fe73177197363b Mon Sep 17 00:00:00 2001 From: Roman Tereshin Date: Tue, 8 May 2018 22:53:09 +0000 Subject: [GlobalISel][Legalizer] More concise and faster widenScalar, NFC Refactoring LegalizerHelper::widenScalar member function reducing its size by approximately a factor of 2 and (hopefuly) making it more straightforward and regular by introducing widenScalarSrc and widenScalarDst helper methods. The new widenScalar* methods mutate the instructions in place instead of recreating them from scratch and removing the originals. The compile time implications of this were measured on sqlite3 amalgamation, targeting AArch64 in -O0: LegalizerHelper::widenScalar: > 25% faster Legalizer::runOnMachineFunction: ~ 4.0 - 4.5% faster Also adding MachineOperand::setCImm and refactoring out MachineIRBuilder::recordInsertion methods to make the change possible. Reviewers: aditya_nandakumar, bogner, javed.absar, t.p.northover, ab, dsanders, arsenm Reviewed By: aditya_nandakumar Subscribers: wdng, rovka, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D46414 llvm-svn: 331819 --- llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp') diff --git a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp index 273044b..a3bf45f 100644 --- a/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp +++ b/llvm/lib/CodeGen/GlobalISel/MachineIRBuilder.cpp @@ -53,6 +53,11 @@ void MachineIRBuilderBase::setInsertPt(MachineBasicBlock &MBB, State.II = II; } +void MachineIRBuilderBase::recordInsertion(MachineInstr *InsertedInstr) const { + if (State.InsertedInstr) + State.InsertedInstr(InsertedInstr); +} + void MachineIRBuilderBase::recordInsertions( std::function Inserted) { State.InsertedInstr = std::move(Inserted); @@ -77,8 +82,7 @@ MachineInstrBuilder MachineIRBuilderBase::buildInstrNoInsert(unsigned Opcode) { MachineInstrBuilder MachineIRBuilderBase::insertInstr(MachineInstrBuilder MIB) { getMBB().insert(getInsertPt(), MIB); - if (State.InsertedInstr) - State.InsertedInstr(MIB); + recordInsertion(MIB); return MIB; } -- cgit v1.1