From f815117481a908e329b55a38982f3c656451e317 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 17 Jun 2004 22:15:25 +0000 Subject: [PATCH] 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 llvm-svn: 14204 --- lib/Target/X86/InstSelectSimple.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index 0c8b0a45667..598a979471a 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -1964,11 +1964,12 @@ void ISel::visitSimpleBinary(BinaryOperator &B, unsigned OperatorClass) { // Special case: op Reg, load [mem] if (isa(Op0) && !isa(Op1) && Class != cLong && + Op0->hasOneUse() && isSafeToFoldLoadIntoInstruction(*cast(Op0), B)) if (!B.swapOperands()) std::swap(Op0, Op1); // Make sure any loads are in the RHS. - if (isa(Op1) && Class != cLong && + if (isa(Op1) && Class != cLong && Op1->hasOneUse() && isSafeToFoldLoadIntoInstruction(*cast(Op1), B)) { unsigned Opcode;