mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-20 19:42:54 +02:00
Fix cases where we generated horrible code like this:
mov %EDI, 12 add %EDI, %ECX mov %ECX, 12 add %ECX, %EDX mov %EDX, 12 add %EDX, %ESI instead (really!) generate this: add %ECX, 12 add %EDX, 12 add %ESI, 12 llvm-svn: 15090
This commit is contained in:
parent
f18cdca667
commit
e3d3cd3e71
@ -2967,8 +2967,9 @@ void ISel::visitLoadInst(LoadInst &I) {
|
|||||||
// Okay, we found a user. If the load is the first operand and there is
|
// Okay, we found a user. If the load is the first operand and there is
|
||||||
// no second operand load, reverse the operand ordering. Note that this
|
// no second operand load, reverse the operand ordering. Note that this
|
||||||
// can fail for a subtract (ie, no change will be made).
|
// can fail for a subtract (ie, no change will be made).
|
||||||
|
bool Swapped = false;
|
||||||
if (!isa<LoadInst>(User->getOperand(1)))
|
if (!isa<LoadInst>(User->getOperand(1)))
|
||||||
cast<BinaryOperator>(User)->swapOperands();
|
Swapped = !cast<BinaryOperator>(User)->swapOperands();
|
||||||
|
|
||||||
// Okay, now that everything is set up, if this load is used by the second
|
// Okay, now that everything is set up, if this load is used by the second
|
||||||
// operand, and if there are no instructions that invalidate the load
|
// operand, and if there are no instructions that invalidate the load
|
||||||
@ -2985,6 +2986,11 @@ void ISel::visitLoadInst(LoadInst &I) {
|
|||||||
User->getOpcode() == Instruction::Div) &&
|
User->getOpcode() == Instruction::Div) &&
|
||||||
isSafeToFoldLoadIntoInstruction(I, *User))
|
isSafeToFoldLoadIntoInstruction(I, *User))
|
||||||
return; // Eliminate the load!
|
return; // Eliminate the load!
|
||||||
|
|
||||||
|
// If we swapped the operands to the instruction, but couldn't fold the
|
||||||
|
// load anyway, swap them back. We don't want to break add X, int
|
||||||
|
// folding.
|
||||||
|
if (Swapped) cast<BinaryOperator>(User)->swapOperands();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user