[x86] Disable invalid checked load/store optimization.
authorBenedikt Meurer <bmeurer@chromium.org>
Tue, 9 Dec 2014 14:16:16 +0000 (15:16 +0100)
committerBenedikt Meurer <bmeurer@chromium.org>
Tue, 9 Dec 2014 14:16:34 +0000 (14:16 +0000)
TEST=mjsunit/compiler/regress-lena
R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/784153006

Cr-Commit-Position: refs/heads/master@{#25722}

src/compiler/ia32/instruction-selector-ia32.cc
src/compiler/x64/instruction-selector-x64.cc
test/mjsunit/compiler/regress-lena.js [new file with mode: 0644]

index f31cc1f..b49b69c 100644 (file)
@@ -454,29 +454,6 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
       UNREACHABLE();
       return;
   }
-  if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
-    Int32Matcher mlength(length);
-    Int32BinopMatcher moffset(offset);
-    if (mlength.HasValue() && moffset.right().HasValue() &&
-        mlength.Value() > moffset.right().Value()) {
-      Int32Matcher mbuffer(buffer);
-      InstructionOperand* offset_operand = g.UseRegister(moffset.left().node());
-      InstructionOperand* length_operand =
-          g.TempImmediate(mlength.Value() - moffset.right().Value());
-      if (mbuffer.HasValue()) {
-        Emit(opcode | AddressingModeField::encode(kMode_MRI),
-             g.DefineAsRegister(node), offset_operand, length_operand,
-             offset_operand,
-             g.TempImmediate(mbuffer.Value() + moffset.right().Value()));
-      } else {
-        Emit(opcode | AddressingModeField::encode(kMode_MR1I),
-             g.DefineAsRegister(node), offset_operand, length_operand,
-             g.UseRegister(buffer), offset_operand,
-             g.UseImmediate(moffset.right().node()));
-      }
-      return;
-    }
-  }
   InstructionOperand* offset_operand = g.UseRegister(offset);
   InstructionOperand* length_operand =
       g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
@@ -525,28 +502,6 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
           ? g.UseImmediate(value)
           : ((rep == kRepWord8 || rep == kRepBit) ? g.UseByteRegister(value)
                                                   : g.UseRegister(value));
-  if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
-    Int32Matcher mbuffer(buffer);
-    Int32Matcher mlength(length);
-    Int32BinopMatcher moffset(offset);
-    if (mlength.HasValue() && moffset.right().HasValue() &&
-        mlength.Value() > moffset.right().Value()) {
-      InstructionOperand* offset_operand = g.UseRegister(moffset.left().node());
-      InstructionOperand* length_operand =
-          g.TempImmediate(mlength.Value() - moffset.right().Value());
-      if (mbuffer.HasValue()) {
-        Emit(opcode | AddressingModeField::encode(kMode_MRI), nullptr,
-             offset_operand, length_operand, value_operand, offset_operand,
-             g.TempImmediate(mbuffer.Value() + moffset.right().Value()));
-      } else {
-        Emit(opcode | AddressingModeField::encode(kMode_MR1I), nullptr,
-             offset_operand, length_operand, value_operand,
-             g.UseRegister(buffer), offset_operand,
-             g.UseImmediate(moffset.right().node()));
-      }
-      return;
-    }
-  }
   InstructionOperand* offset_operand = g.UseRegister(offset);
   InstructionOperand* length_operand =
       g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
index 95ba897..a8a9f9d 100644 (file)
@@ -230,21 +230,6 @@ void InstructionSelector::VisitCheckedLoad(Node* node) {
       UNREACHABLE();
       return;
   }
-  if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
-    Int32Matcher mlength(length);
-    Int32BinopMatcher moffset(offset);
-    if (mlength.HasValue() && moffset.right().HasValue() &&
-        mlength.Value() > moffset.right().Value()) {
-      InstructionOperand* offset_operand = g.UseRegister(moffset.left().node());
-      InstructionOperand* length_operand =
-          g.TempImmediate(mlength.Value() - moffset.right().Value());
-      Emit(opcode | AddressingModeField::encode(kMode_MR1I),
-           g.DefineAsRegister(node), offset_operand, length_operand,
-           g.UseRegister(buffer), offset_operand,
-           g.UseImmediate(moffset.right().node()));
-      return;
-    }
-  }
   InstructionOperand* offset_operand = g.UseRegister(offset);
   InstructionOperand* length_operand =
       g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
@@ -284,20 +269,6 @@ void InstructionSelector::VisitCheckedStore(Node* node) {
   }
   InstructionOperand* value_operand =
       g.CanBeImmediate(value) ? g.UseImmediate(value) : g.UseRegister(value);
-  if (offset->opcode() == IrOpcode::kInt32Add && CanCover(node, offset)) {
-    Int32Matcher mlength(length);
-    Int32BinopMatcher moffset(offset);
-    if (mlength.HasValue() && moffset.right().HasValue() &&
-        mlength.Value() > moffset.right().Value()) {
-      InstructionOperand* offset_operand = g.UseRegister(moffset.left().node());
-      InstructionOperand* length_operand =
-          g.TempImmediate(mlength.Value() - moffset.right().Value());
-      Emit(opcode | AddressingModeField::encode(kMode_MR1I), nullptr,
-           offset_operand, length_operand, value_operand, g.UseRegister(buffer),
-           offset_operand, g.UseImmediate(moffset.right().node()));
-      return;
-    }
-  }
   InstructionOperand* offset_operand = g.UseRegister(offset);
   InstructionOperand* length_operand =
       g.CanBeImmediate(length) ? g.UseImmediate(length) : g.UseRegister(length);
diff --git a/test/mjsunit/compiler/regress-lena.js b/test/mjsunit/compiler/regress-lena.js
new file mode 100644 (file)
index 0000000..288e2a4
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+function module(stdlib, foreign, heap) {
+    "use asm";
+    var MEM32 = new stdlib.Int32Array(heap);
+    function foo(i) {
+      i = i|0;
+      MEM32[0] = i;
+      return MEM32[i + 4 >> 2]|0;
+    }
+    return { foo: foo };
+}
+
+var foo = module(this, {}, new ArrayBuffer(64*1024)).foo;
+assertEquals(-4, foo(-4));