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 | ada5d6c37e2938fe56719ea37d9581320222998c (patch) | |
tree | bcdec7d65b1e2a768f183d98f41118c855a07757 /llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | |
parent | 99a8cb627dfac4f040503456dd0690815283b79e (diff) | |
download | bcm5719-llvm-ada5d6c37e2938fe56719ea37d9581320222998c.tar.gz bcm5719-llvm-ada5d6c37e2938fe56719ea37d9581320222998c.zip |
optimize FastISel::UpdateValueMap to avoid duplicate map lookups,
and make it return the assigned register.
llvm-svn: 68888
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index 8467330bb9b..7e300536748 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/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) { |