[vmkit-commits] [vmkit] r144135 - in /vmkit/trunk: lib/J3/Compiler/JavaJITOpcodes.cpp test/lshr.java

Will Dietz wdietz2 at illinois.edu
Tue Nov 8 14:08:32 PST 2011


Author: wdietz2
Date: Tue Nov  8 16:08:32 2011
New Revision: 144135

URL: http://llvm.org/viewvc/llvm-project?rev=144135&view=rev
Log:
Fix LSHR by masking the shift operand.

Sample test case added.

java produces (Hotspot 1.6.0_27):
1
0
0
1
1
0

j3 before this patch produces:
1
0
0
0
0
0

Added:
    vmkit/trunk/test/lshr.java
Modified:
    vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=144135&r1=144134&r2=144135&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Tue Nov  8 16:08:32 2011
@@ -1207,6 +1207,8 @@
 
       case LSHR : {
         Value* val2 = new ZExtInst(pop(), Type::getInt64Ty(*llvmContext), "", currentBlock);
+        Value* mask = ConstantInt::get(Type::getInt64Ty(*llvmContext), 0x3F);
+        val2 = BinaryOperator::CreateAnd(val2, mask, "", currentBlock);
         pop(); // remove the 0 on the stack
         Value* val1 = pop();
         push(BinaryOperator::CreateAShr(val1, val2, "", currentBlock),

Added: vmkit/trunk/test/lshr.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/test/lshr.java?rev=144135&view=auto
==============================================================================
--- vmkit/trunk/test/lshr.java (added)
+++ vmkit/trunk/test/lshr.java Tue Nov  8 16:08:32 2011
@@ -0,0 +1,15 @@
+class lshr {
+  public static void check(boolean b) throws Exception {
+    if (!b) throw new Exception("Check failed!");
+  }
+
+  public static void main(String[] args) throws Exception {
+    long l = 1;
+    check(l == 1);
+    check(l >> 10 == 0);
+    check(l >> 32 == 0);
+    check(l >> 64 == 1);
+    check(l >> 128 == 1);
+    check(l >> -10 == 0);
+  }
+}





More information about the vmkit-commits mailing list