Permalink
Browse files

2002-05-11 Dietmar Maurer <dietmar@ximian.com>

	* x86.brg: bug fix in SHR/SHL

svn path=/trunk/mono/; revision=4518
  • Loading branch information...
1 parent cc5deac commit 9c4653049adcb6015bb9b9b9a1467843a68d46b4 Dietmar Maurer committed May 11, 2002
Showing with 43 additions and 7 deletions.
  1. +2 −0 mono/jit/ChangeLog
  2. +23 −7 mono/jit/x86.brg
  3. +1 −0 mono/tests/Makefile.am
  4. +17 −0 mono/tests/shift.cs
View
@@ -1,5 +1,7 @@
2002-05-11 Dietmar Maurer <dietmar@ximian.com>
+ * x86.brg: bug fix in SHR/SHL
+
* emit-x86.c (arch_emit_prologue): check if live_in_set != NULL
2002-05-11 Sergey Chaban <serge@wildwestsoftware.com>
View
@@ -542,7 +542,6 @@ stmt: STIND_I4 (addr, coni4) {
}
stmt: STIND_I4 (addr, reg) {
- PRINT_REG ("STIND_I4", tree->right->reg1);
switch (tree->left->data.ainfo.amode) {
@@ -1522,15 +1521,20 @@ reg: SHL (reg, coni4) {
}
reg: SHL (reg, reg) {
- if (tree->right->reg1 != X86_ECX)
+ if (tree->right->reg1 != X86_ECX) {
+ x86_push_reg (s->code, X86_ECX);
x86_mov_reg_reg (s->code, X86_ECX, tree->right->reg1, 4);
+ }
x86_shift_reg (s->code, X86_SHL, tree->left->reg1);
if (tree->reg1 != tree->left->reg1)
x86_mov_reg_reg (s->code, tree->reg1, tree->left->reg1, 4);
+ if (tree->right->reg1 != X86_ECX)
+ x86_pop_reg (s->code, X86_ECX);
+
mono_assert (tree->reg1 != X86_ECX &&
- tree->left->reg1 != X86_ECX);
+ tree->left->reg1 != X86_ECX);
}
reg: SHR (reg, coni4) {
@@ -1541,15 +1545,21 @@ reg: SHR (reg, coni4) {
}
reg: SHR (reg, reg) {
- if (tree->right->reg1 != X86_ECX)
+ if (tree->right->reg1 != X86_ECX) {
+ x86_push_reg (s->code, X86_ECX);
x86_mov_reg_reg (s->code, X86_ECX, tree->right->reg1, 4);
+ }
+
x86_shift_reg (s->code, X86_SAR, tree->left->reg1);
if (tree->reg1 != tree->left->reg1)
x86_mov_reg_reg (s->code, tree->reg1, tree->left->reg1, 4);
+ if (tree->right->reg1 != X86_ECX)
+ x86_pop_reg (s->code, X86_ECX);
+
mono_assert (tree->reg1 != X86_ECX &&
- tree->left->reg1 != X86_ECX);
+ tree->left->reg1 != X86_ECX);
}
reg: SHR_UN (reg, coni4) {
@@ -1560,15 +1570,21 @@ reg: SHR_UN (reg, coni4) {
}
reg: SHR_UN (reg, reg) {
- if (tree->right->reg1 != X86_ECX)
+ if (tree->right->reg1 != X86_ECX) {
+ x86_push_reg (s->code, X86_ECX);
x86_mov_reg_reg (s->code, X86_ECX, tree->right->reg1, 4);
+ }
+
x86_shift_reg (s->code, X86_SHR, tree->left->reg1);
if (tree->reg1 != tree->left->reg1)
x86_mov_reg_reg (s->code, tree->reg1, tree->left->reg1, 4);
+ if (tree->right->reg1 != X86_ECX)
+ x86_pop_reg (s->code, X86_ECX);
+
mono_assert (tree->reg1 != X86_ECX &&
- tree->left->reg1 != X86_ECX);
+ tree->left->reg1 != X86_ECX);
}
reg: LDSFLDA (coni4) {
@@ -71,6 +71,7 @@ TESTSRC= \
indexer.cs \
stream.cs \
console.cs \
+ shift.cs \
jit-int.cs \
jit-uint.cs \
jit-long.cs \
View
@@ -0,0 +1,17 @@
+using System;
+
+class Test {
+ public static int Main () {
+ int [] n = new int [1];
+ int b = 16;
+
+ n [0] = 100 + (1 << (16 - b));
+ Console.WriteLine (n [0]);
+
+ if (n [0] != 101)
+ return 1;
+
+ return 0;
+ }
+}
+

0 comments on commit 9c46530

Please sign in to comment.