An intrinsic was my first thought as well. It would seem quite appropriate to have an operation or set of operations on java.lang.Math for example that we all could use.
Perhaps I should have asked this six months ago :) - Charlie (mobile) On May 3, 2011, at 11:44, Christian Thalinger <christian.thalin...@oracle.com> wrote: > On May 3, 2011, at 5:06 PM, Rémi Forax wrote: >> On 05/03/2011 03:59 PM, Christian Thalinger wrote: >>> On May 2, 2011, at 9:55 PM, Charles Oliver Nutter wrote: >>>> On Thu, Apr 28, 2011 at 11:18 AM, Rémi Forax<fo...@univ-mlv.fr> wrote: >>>>> Do you specialize the overflow check depending on the callsite ? >>>>> for fib(n - 1), you just have to check if n is different from >>>>> Integer.MIN_INT, >>>>> for fib(n - 2), if n is<= to Integer.MIN_INT - 1 >>>>> and for + use the double xor tricks. >>>> Here's a related question. Is there a way we can structure the double >>>> xor trick to get Hotspot to intrinsify it as a jc instruction or >>>> similar? >>>> >>>> As I posted earlier, we use the "double xor" trick, which I would >>>> expect JVM could recognize as a carry check and do the right thing. Or >>>> perhaps there's an intrinsic somewhere in JVM/JDK we could call? >>> I look a little into this and as far as I know there is nothing you could >>> call. I also tried to hack something into the backend and I think that >>> could work. I'm just not sure how many users would trigger that pattern. >>> >>> -- Christian >> >> The pattern occurs enough often to be recognized as a pattern. >> >> Here is the version used by JSR 310 reference implementation: >> http://threeten.svn.sourceforge.net/viewvc/threeten/trunk/threeten/src/main/java/javax/time/MathUtils.java?revision=1417&view=markup >> (look for safeAdd) >> >> It uses a && instead of a & in the middle, >> I don't know which one is the better. > > That's interesting, thank you. Intrinsifying a Java method would definitely > be easier than doing something in the backend but I will look at it again. > > -- Christian > > _______________________________________________ > mlvm-dev mailing list > mlvm-dev@openjdk.java.net > http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev _______________________________________________ mlvm-dev mailing list mlvm-dev@openjdk.java.net http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev