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

Chris Lattner lattner at cs.uiuc.edu
Thu Jun 17 17:22:01 PDT 2004


Changes in directory llvm/lib/Target/X86:

InstSelectSimple.cpp updated: 1.264 -> 1.265

---
Log message:

Do not fold loads into instructions if it is used more than once.  In particular
we do not want to fold the load in cases like this:

  X = load
    = add A, X
    = add B, X



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

Index: llvm/lib/Target/X86/InstSelectSimple.cpp
diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.264 llvm/lib/Target/X86/InstSelectSimple.cpp:1.265
--- llvm/lib/Target/X86/InstSelectSimple.cpp:1.264	Thu Jun 17 13:17:22 2004
+++ llvm/lib/Target/X86/InstSelectSimple.cpp	Thu Jun 17 17:15:25 2004
@@ -1964,11 +1964,12 @@
 
   // Special case: op Reg, load [mem]
   if (isa<LoadInst>(Op0) && !isa<LoadInst>(Op1) && Class != cLong &&
+      Op0->hasOneUse() && 
       isSafeToFoldLoadIntoInstruction(*cast<LoadInst>(Op0), B))
     if (!B.swapOperands())
       std::swap(Op0, Op1);  // Make sure any loads are in the RHS.
 
-  if (isa<LoadInst>(Op1) && Class != cLong &&
+  if (isa<LoadInst>(Op1) && Class != cLong && Op1->hasOneUse() &&
       isSafeToFoldLoadIntoInstruction(*cast<LoadInst>(Op1), B)) {
 
     unsigned Opcode;





More information about the llvm-commits mailing list