diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-06 01:25:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-06 01:25:33 +0000 |
commit | 502e36c3c95c6bf65094ae6a6ca52d7ff4e13d68 (patch) | |
tree | 5a220020237ac0caba2578d2abf79643be65bed4 | |
parent | 29bf0623e57d36b982955a2cc7bf48d856c26d84 (diff) | |
download | external_llvm-502e36c3c95c6bf65094ae6a6ca52d7ff4e13d68.zip external_llvm-502e36c3c95c6bf65094ae6a6ca52d7ff4e13d68.tar.gz external_llvm-502e36c3c95c6bf65094ae6a6ca52d7ff4e13d68.tar.bz2 |
Minor tweak to avoid an extra reg-reg copy that the register allocator has to eliminate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12680 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/InstSelectSimple.cpp | 11 | ||||
-rw-r--r-- | lib/Target/X86/X86ISelSimple.cpp | 11 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index 25f67ec..6144b62 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -1109,12 +1109,21 @@ void ISel::promote32(unsigned targetReg, const ValueRecord &VR) { Value *Val = VR.Val; const Type *Ty = VR.Ty; - if (Val) + if (Val) { if (Constant *C = dyn_cast<Constant>(Val)) { Val = ConstantExpr::getCast(C, Type::IntTy); Ty = Type::IntTy; } + // If this is a simple constant, just emit a MOVri directly to avoid the + // copy. + if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) { + int TheVal = CI->getRawValue() & 0xFFFFFFFF; + BuildMI(BB, X86::MOV32ri, 1, targetReg).addImm(TheVal); + return; + } + } + // Make sure we have the register number for this value... unsigned Reg = Val ? getReg(Val) : VR.Reg; diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp index 25f67ec..6144b62 100644 --- a/lib/Target/X86/X86ISelSimple.cpp +++ b/lib/Target/X86/X86ISelSimple.cpp @@ -1109,12 +1109,21 @@ void ISel::promote32(unsigned targetReg, const ValueRecord &VR) { Value *Val = VR.Val; const Type *Ty = VR.Ty; - if (Val) + if (Val) { if (Constant *C = dyn_cast<Constant>(Val)) { Val = ConstantExpr::getCast(C, Type::IntTy); Ty = Type::IntTy; } + // If this is a simple constant, just emit a MOVri directly to avoid the + // copy. + if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) { + int TheVal = CI->getRawValue() & 0xFFFFFFFF; + BuildMI(BB, X86::MOV32ri, 1, targetReg).addImm(TheVal); + return; + } + } + // Make sure we have the register number for this value... unsigned Reg = Val ? getReg(Val) : VR.Reg; |