[x86] Fix register constraints for multiply high and modulus.
authorbmeurer@chromium.org <bmeurer@chromium.org>
Mon, 3 Nov 2014 06:27:34 +0000 (06:27 +0000)
committerbmeurer@chromium.org <bmeurer@chromium.org>
Mon, 3 Nov 2014 06:28:12 +0000 (06:28 +0000)
R=jarin@chromium.org
TEST=mjsunit/compiler/regress-register-allocator2

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

Cr-Commit-Position: refs/heads/master@{#25054}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25054 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

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

index f4358ea..1dd9c16 100644 (file)
@@ -648,10 +648,9 @@ void InstructionSelector::VisitInt32Mul(Node* node) {
 
 void InstructionSelector::VisitInt32MulHigh(Node* node) {
   IA32OperandGenerator g(this);
-  InstructionOperand* temps[] = {g.TempRegister(eax)};
   Emit(kIA32ImulHigh, g.DefineAsFixed(node, edx),
-       g.UseFixed(node->InputAt(0), eax), g.UseUniqueRegister(node->InputAt(1)),
-       arraysize(temps), temps);
+       g.UseFixed(node->InputAt(0), eax),
+       g.UseUniqueRegister(node->InputAt(1)));
 }
 
 
@@ -679,11 +678,9 @@ void InstructionSelector::VisitUint32Div(Node* node) {
 static inline void VisitMod(InstructionSelector* selector, Node* node,
                             ArchOpcode opcode) {
   IA32OperandGenerator g(selector);
-  InstructionOperand* temps[] = {g.TempRegister(eax), g.TempRegister(edx)};
-  size_t temp_count = arraysize(temps);
   selector->Emit(opcode, g.DefineAsFixed(node, edx),
                  g.UseFixed(node->InputAt(0), eax),
-                 g.UseUnique(node->InputAt(1)), temp_count, temps);
+                 g.UseUnique(node->InputAt(1)));
 }
 
 
index f49f8bf..432b21c 100644 (file)
@@ -420,10 +420,9 @@ void InstructionSelector::VisitInt64Mul(Node* node) {
 
 void InstructionSelector::VisitInt32MulHigh(Node* node) {
   X64OperandGenerator g(this);
-  InstructionOperand* temps[] = {g.TempRegister(rax)};
   Emit(kX64ImulHigh32, g.DefineAsFixed(node, rdx),
-       g.UseFixed(node->InputAt(0), rax), g.UseUniqueRegister(node->InputAt(1)),
-       arraysize(temps), temps);
+       g.UseFixed(node->InputAt(0), rax),
+       g.UseUniqueRegister(node->InputAt(1)));
 }
 
 
@@ -460,10 +459,9 @@ void InstructionSelector::VisitUint64Div(Node* node) {
 static void VisitMod(InstructionSelector* selector, Node* node,
                      ArchOpcode opcode) {
   X64OperandGenerator g(selector);
-  InstructionOperand* temps[] = {g.TempRegister(rax), g.TempRegister(rdx)};
-  selector->Emit(
-      opcode, g.DefineAsFixed(node, rdx), g.UseFixed(node->InputAt(0), rax),
-      g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps);
+  selector->Emit(opcode, g.DefineAsFixed(node, rdx),
+                 g.UseFixed(node->InputAt(0), rax),
+                 g.UseUniqueRegister(node->InputAt(1)));
 }
 
 
diff --git a/test/mjsunit/compiler/regress-register-allocator2.js b/test/mjsunit/compiler/regress-register-allocator2.js
new file mode 100644 (file)
index 0000000..06e0c49
--- /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 f() {
+  var x = 0;
+  var y = 0;
+  x ^= undefined;
+  assertEquals(x /= 1);
+  assertEquals(NaN, y %= 1);
+  assertEquals(y = 1);
+  f();
+  y = -2;
+  assertEquals(x >>= 1);
+  assertEquals(0, ((y+(y+(y+((y^(x%5))+y)))+(y+y))>>y)+y);
+}
+try { f(); } catch (e) {}