# HG changeset patch # User Lukas Stadler # Date 1403538334 -7200 # Node ID 0244e5bdddc140a8bf75bf74dfe27dbb05f02ccc # Parent 3d76b518b0071a4158463940d6d4052321cc47a1 intrinsify unsigned operations in java.lang.Integer/Long diff -r 3d76b518b007 -r 0244e5bdddc1 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedDivNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedDivNode.java Mon Jun 23 17:03:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedDivNode.java Mon Jun 23 17:45:34 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,6 @@ /** * Used by {@code NodeIntrinsic} in {@code UnsignedMathSubstitutions}. */ - @SuppressWarnings("unused") private UnsignedDivNode(Kind kind, ValueNode x, ValueNode y) { this(StampFactory.forKind(kind), x, y); } @@ -79,4 +78,10 @@ public boolean canDeoptimize() { return !(y().stamp() instanceof IntegerStamp) || ((IntegerStamp) y().stamp()).contains(0); } + + @NodeIntrinsic + public static native int unsignedDivide(@ConstantNodeParameter Kind kind, int a, int b); + + @NodeIntrinsic + public static native long unsignedDivide(@ConstantNodeParameter Kind kind, long a, long b); } diff -r 3d76b518b007 -r 0244e5bdddc1 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java Mon Jun 23 17:03:21 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/UnsignedRemNode.java Mon Jun 23 17:45:34 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,6 @@ /** * Used by {@code NodeIntrinsic} in {@code UnsignedMathSubstitutions}. */ - @SuppressWarnings("unused") private UnsignedRemNode(Kind kind, ValueNode x, ValueNode y) { this(StampFactory.forKind(kind), x, y); } @@ -78,4 +77,10 @@ public boolean canDeoptimize() { return !(y().stamp() instanceof IntegerStamp) || ((IntegerStamp) y().stamp()).contains(0); } + + @NodeIntrinsic + public static native int unsignedRemainder(@ConstantNodeParameter Kind kind, int a, int b); + + @NodeIntrinsic + public static native long unsignedRemainder(@ConstantNodeParameter Kind kind, long a, long b); } diff -r 3d76b518b007 -r 0244e5bdddc1 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java Mon Jun 23 17:03:21 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/IntegerSubstitutions.java Mon Jun 23 17:45:34 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,9 @@ */ package com.oracle.graal.replacements; +import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; +import com.oracle.graal.nodes.calc.*; import com.oracle.graal.replacements.nodes.*; @ClassSubstitution(Integer.class) @@ -53,4 +55,14 @@ public static int bitCount(int i) { return BitCountNode.bitCount(i); } + + @MethodSubstitution + public static int divideUnsigned(int dividend, int divisor) { + return UnsignedDivNode.unsignedDivide(Kind.Int, dividend, divisor); + } + + @MethodSubstitution + public static int remainderUnsigned(int dividend, int divisor) { + return UnsignedRemNode.unsignedRemainder(Kind.Int, dividend, divisor); + } } diff -r 3d76b518b007 -r 0244e5bdddc1 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java Mon Jun 23 17:03:21 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/LongSubstitutions.java Mon Jun 23 17:45:34 2014 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,9 @@ */ package com.oracle.graal.replacements; +import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; +import com.oracle.graal.nodes.calc.*; import com.oracle.graal.replacements.nodes.*; @ClassSubstitution(Long.class) @@ -53,4 +55,14 @@ public static int bitCount(long i) { return BitCountNode.bitCount(i); } + + @MethodSubstitution + public static long divideUnsigned(long dividend, long divisor) { + return UnsignedDivNode.unsignedDivide(Kind.Long, dividend, divisor); + } + + @MethodSubstitution + public static long remainderUnsigned(long dividend, long divisor) { + return UnsignedRemNode.unsignedRemainder(Kind.Long, dividend, divisor); + } }