Index: src/compiler/x64/instruction-selector-x64.cc |
diff --git a/src/compiler/x64/instruction-selector-x64.cc b/src/compiler/x64/instruction-selector-x64.cc |
index 8e68b96d7a529514b514448f305c9d72f186e3f8..7aba7913aef5b503b7033d24a84d84344219dadc 100644 |
--- a/src/compiler/x64/instruction-selector-x64.cc |
+++ b/src/compiler/x64/instruction-selector-x64.cc |
@@ -37,11 +37,15 @@ class X64OperandGenerator final : public OperandGenerator { |
} |
} |
- bool CanBeMemoryOperand(InstructionCode opcode, Node* node, Node* input) { |
+ bool CanBeMemoryOperand(InstructionCode opcode, Node* node, Node* input, |
+ int effect_level) { |
if (input->opcode() != IrOpcode::kLoad || |
!selector()->CanCover(node, input)) { |
return false; |
} |
+ if (effect_level != selector()->GetEffectLevel(input)) { |
+ return false; |
+ } |
MachineRepresentation rep = |
LoadRepresentationOf(input->op()).representation(); |
switch (opcode) { |
@@ -1548,16 +1552,22 @@ void VisitWordCompare(InstructionSelector* selector, Node* node, |
// If one of the two inputs is an immediate, make sure it's on the right, or |
// if one of the two inputs is a memory operand, make sure it's on the left. |
+ int effect_level = selector->GetEffectLevel(node); |
+ if (cont->IsBranch()) { |
+ effect_level = selector->GetEffectLevel( |
+ cont->true_block()->PredecessorAt(0)->control_input()); |
+ } |
+ |
if ((!g.CanBeImmediate(right) && g.CanBeImmediate(left)) || |
- (g.CanBeMemoryOperand(opcode, node, right) && |
- !g.CanBeMemoryOperand(opcode, node, left))) { |
+ (g.CanBeMemoryOperand(opcode, node, right, effect_level) && |
+ !g.CanBeMemoryOperand(opcode, node, left, effect_level))) { |
if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); |
std::swap(left, right); |
} |
// Match immediates on right side of comparison. |
if (g.CanBeImmediate(right)) { |
- if (g.CanBeMemoryOperand(opcode, node, left)) { |
+ if (g.CanBeMemoryOperand(opcode, node, left, effect_level)) { |
return VisitCompareWithMemoryOperand(selector, opcode, left, |
g.UseImmediate(right), cont); |
} |
@@ -1566,7 +1576,7 @@ void VisitWordCompare(InstructionSelector* selector, Node* node, |
} |
// Match memory operands on left side of comparison. |
- if (g.CanBeMemoryOperand(opcode, node, left)) { |
+ if (g.CanBeMemoryOperand(opcode, node, left, effect_level)) { |
return VisitCompareWithMemoryOperand(selector, opcode, left, |
g.UseRegister(right), cont); |
} |