[llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Apr 5 20:26:01 PDT 2004


Changes in directory llvm/lib/Target/X86:

InstSelectSimple.cpp updated: 1.205 -> 1.206

---
Log message:

Minor tweak to avoid an extra reg-reg copy that the register allocator has to eliminate


---
Diffs of the changes:  (+10 -1)

Index: llvm/lib/Target/X86/InstSelectSimple.cpp
diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.205 llvm/lib/Target/X86/InstSelectSimple.cpp:1.206
--- llvm/lib/Target/X86/InstSelectSimple.cpp:1.205	Mon Apr  5 20:21:00 2004
+++ llvm/lib/Target/X86/InstSelectSimple.cpp	Mon Apr  5 20:25:33 2004
@@ -1109,11 +1109,20 @@
 
   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;





More information about the llvm-commits mailing list