Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1174)

Unified Diff: src/compiler/x64/instruction-selector-x64.cc

Issue 2008493002: [x64/ia32] Deal with the non-transitivity of InstructionSelector::CanCover() when folding loads int… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | test/cctest/compiler/test-branch-combine.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « src/compiler/instruction-selector.cc ('k') | test/cctest/compiler/test-branch-combine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698