diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-12 07:45:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-12 07:45:01 +0000 |
commit | bc846230e533883273d3a6d44b303ce421b6ba02 (patch) | |
tree | 0107e752b42bab2c0844a568499a2e35a3049608 /lib | |
parent | a6a19bd91489f801217073988829d3add58a69fc (diff) | |
download | external_llvm-bc846230e533883273d3a6d44b303ce421b6ba02.zip external_llvm-bc846230e533883273d3a6d44b303ce421b6ba02.tar.gz external_llvm-bc846230e533883273d3a6d44b303ce421b6ba02.tar.bz2 |
optimize FastISel::UpdateValueMap to avoid duplicate map lookups,
and make it return the assigned register.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68888 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 8467330..7e30053 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -149,16 +149,21 @@ unsigned FastISel::lookUpRegForValue(Value *V) { /// NOTE: This is only necessary because we might select a block that uses /// a value before we select the block that defines the value. It might be /// possible to fix this by selecting blocks in reverse postorder. -void FastISel::UpdateValueMap(Value* I, unsigned Reg) { +unsigned FastISel::UpdateValueMap(Value* I, unsigned Reg) { if (!isa<Instruction>(I)) { LocalValueMap[I] = Reg; - return; + return Reg; + } + + unsigned &AssignedReg = ValueMap[I]; + if (AssignedReg == 0) + AssignedReg = Reg; + else { + const TargetRegisterClass *RegClass = MRI.getRegClass(Reg); + TII.copyRegToReg(*MBB, MBB->end(), AssignedReg, + Reg, RegClass, RegClass); } - if (!ValueMap.count(I)) - ValueMap[I] = Reg; - else - TII.copyRegToReg(*MBB, MBB->end(), ValueMap[I], - Reg, MRI.getRegClass(Reg), MRI.getRegClass(Reg)); + return AssignedReg; } unsigned FastISel::getRegForGEPIndex(Value *Idx) { |