[vmkit-commits] [PATCH] Fix LSHR by masking the shift operand.
Nicolas Geoffray
nicolas.geoffray at gmail.com
Tue Nov 8 12:52:09 PST 2011
Please apply, with same comment of adding the test to the tests/ directory.
Thanks!
On Mon, Nov 7, 2011 at 9:16 PM, Will Dietz <wdietz2 at illinois.edu> wrote:
> Same thing as previous LSHL patch, only for LSHR.
>
> ~Will
>
> >From fc51294c2ddb78189092fd87ed4950ecdb6f43c0 Mon Sep 17 00:00:00 2001
> From: Will Dietz <w at wdtz.org>
> Date: Mon, 7 Nov 2011 13:56:25 -0600
> Subject: [PATCH] Fix LSHR by masking the shift operand.
>
> Sample test case:
>
> class Test {
> public static void main(String[] args) {
> long l = 1;
> System.out.println(l);
> System.out.println(l >> 10);
> System.out.println(l >> 32);
> System.out.println(l >> 64);
> System.out.println(l >> 128);
> System.out.println(l >> -10);
> }
> }
>
> java produces (Hotspot 1.6.0_27):
> 1
> 0
> 0
> 1
> 1
> 0
>
> j3 before this patch produces:
> 1
> 0
> 0
> 0
> 0
> 0
> ---
> lib/J3/Compiler/JavaJITOpcodes.cpp | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/lib/J3/Compiler/JavaJITOpcodes.cpp
> b/lib/J3/Compiler/JavaJITOpcodes.cpp
> index 93b9c3c..682e406 100644
> --- a/lib/J3/Compiler/JavaJITOpcodes.cpp
> +++ b/lib/J3/Compiler/JavaJITOpcodes.cpp
> @@ -1207,6 +1207,8 @@ void JavaJIT::compileOpcodes(Reader& reader,
> uint32 codeLength) {
>
> 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),
> --
> 1.7.5.1
> _______________________________________________
> vmkit-commits mailing list
> vmkit-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/vmkit-commits/attachments/20111108/07cae55c/attachment.html>
More information about the vmkit-commits
mailing list