diff options
| author | Nate Begeman <natebegeman@mac.com> | 2004-11-08 02:25:40 +0000 | 
|---|---|---|
| committer | Nate Begeman <natebegeman@mac.com> | 2004-11-08 02:25:40 +0000 | 
| commit | 0822032c95bc2482dea75bffc79c13897399ae39 (patch) | |
| tree | 2da1eebfb0e43e3bc579564c0deceb62a1c70c11 /llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp | |
| parent | 3fbf26aebe69d4ca6b0510371c32fea226293f5b (diff) | |
| download | bcm5719-llvm-0822032c95bc2482dea75bffc79c13897399ae39.tar.gz bcm5719-llvm-0822032c95bc2482dea75bffc79c13897399ae39.zip | |
Put int the getReg cast optimization from x86 so that we generate fewer
move instructions for the register allocator to coalesce.
llvm-svn: 17608
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp | 8 | 
1 files changed, 8 insertions, 0 deletions
| diff --git a/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp b/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp index 1dd946a421f..0e8b7b04c56 100644 --- a/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp +++ b/llvm/lib/Target/PowerPC/PPC32ISelSimple.cpp @@ -502,6 +502,10 @@ unsigned PPC32ISel::getReg(Value *V, MachineBasicBlock *MBB,      unsigned Reg = makeAnotherReg(V->getType());      copyConstantToRegister(MBB, IPt, C, Reg);      return Reg; +  } else if (CastInst *CI = dyn_cast<CastInst>(V)) { +    // Do not emit noop casts at all, unless it's a double -> float cast. +    if (getClassB(CI->getType()) == getClassB(CI->getOperand(0)->getType())) +      return getReg(CI->getOperand(0), MBB, IPt);    } else if (AllocaInst *AI = dyn_castFixedAlloca(V)) {      unsigned Reg = makeAnotherReg(V->getType());      unsigned FI = getFixedSizedAllocaFI(AI); @@ -3129,6 +3133,10 @@ void PPC32ISel::visitCastInst(CastInst &CI) {    unsigned SrcClass = getClassB(Op->getType());    unsigned DestClass = getClassB(CI.getType()); +  // Noop casts are not emitted: getReg will return the source operand as the +  // register to use for any uses of the noop cast. +  if (DestClass == SrcClass) return; +    // If this is a cast from a 32-bit integer to a Long type, and the only uses    // of the cast are GEP instructions, then the cast does not need to be    // generated explicitly, it will be folded into the GEP. | 

