Fix a fairly serious pessimizaion that was preventing us from efficiently
authorChris Lattner <sabre@nondot.org>
Mon, 10 May 2004 15:15:55 +0000 (15:15 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 10 May 2004 15:15:55 +0000 (15:15 +0000)
compiling things like 'add long %X, 1'.  The problem is that we were switching
the order of the operands for longs even though we can't fold them yet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13451 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/InstSelectSimple.cpp
lib/Target/X86/X86ISelSimple.cpp

index 38503886de025c2b3c6d473af929f9a9b35f405e..8fbeeb7f2e9afeeb91efe72976c43a7ac949f1ef 100644 (file)
@@ -1863,13 +1863,14 @@ void ISel::visitSimpleBinary(BinaryOperator &B, unsigned OperatorClass) {
   unsigned DestReg = getReg(B);
   MachineBasicBlock::iterator MI = BB->end();
   Value *Op0 = B.getOperand(0), *Op1 = B.getOperand(1);
+  unsigned Class = getClassB(B.getType());
 
   // Special case: op Reg, load [mem]
-  if (isa<LoadInst>(Op0) && !isa<LoadInst>(Op1))
+  if (isa<LoadInst>(Op0) && !isa<LoadInst>(Op1) && Class != cLong &&
+      isSafeToFoldLoadIntoInstruction(*cast<LoadInst>(Op0), B))
     if (!B.swapOperands())
       std::swap(Op0, Op1);  // Make sure any loads are in the RHS.
 
-  unsigned Class = getClassB(B.getType());
   if (isa<LoadInst>(Op1) && Class != cLong &&
       isSafeToFoldLoadIntoInstruction(*cast<LoadInst>(Op1), B)) {
 
index 38503886de025c2b3c6d473af929f9a9b35f405e..8fbeeb7f2e9afeeb91efe72976c43a7ac949f1ef 100644 (file)
@@ -1863,13 +1863,14 @@ void ISel::visitSimpleBinary(BinaryOperator &B, unsigned OperatorClass) {
   unsigned DestReg = getReg(B);
   MachineBasicBlock::iterator MI = BB->end();
   Value *Op0 = B.getOperand(0), *Op1 = B.getOperand(1);
+  unsigned Class = getClassB(B.getType());
 
   // Special case: op Reg, load [mem]
-  if (isa<LoadInst>(Op0) && !isa<LoadInst>(Op1))
+  if (isa<LoadInst>(Op0) && !isa<LoadInst>(Op1) && Class != cLong &&
+      isSafeToFoldLoadIntoInstruction(*cast<LoadInst>(Op0), B))
     if (!B.swapOperands())
       std::swap(Op0, Op1);  // Make sure any loads are in the RHS.
 
-  unsigned Class = getClassB(B.getType());
   if (isa<LoadInst>(Op1) && Class != cLong &&
       isSafeToFoldLoadIntoInstruction(*cast<LoadInst>(Op1), B)) {