Re: [cp-patches] Float/Double compare

2007-10-12 Thread Andrew John Hughes
On Tuesday 03 July 2007 23:16:19 Ian Rogers wrote: Here's a revised version of the patch following suggestions from Andrew Haley. Ian Committed: 2007-10-12 Ian Rogers [EMAIL PROTECTED] 2007-10-12 Andrew Haley [EMAIL PROTECTED] PR classpath/33741: * java/lang/Double.java:

Re: [cp-patches] Float/Double compare

2007-07-03 Thread Ian Rogers
Here's a revised version of the patch following suggestions from Andrew Haley. Ian --- java/lang/Float.java2006-12-10 15:25:44.0 -0500 +++ java/lang/Float.java2007-07-02 12:17:29.0 -0400 @@ -596,16 +596,25 @@ */ public static int compare(float x, float y)

Re: Float/Double compare

2007-07-02 Thread Andrew Haley
Ian Rogers writes: Ian Rogers wrote: public static int compare(float x, float y) { if (isNaN(x)) return isNaN(y) ? 0 : 1; if (isNaN(y)) return -1; // recall that 0.0 == -0.0, so we convert to infinities and try again if (x == 0 y == 0)

Re: Float/Double compare

2007-07-02 Thread Ian Rogers
Andrew Haley wrote: We know that any calculation involving NaN returns false, right? So, simple cases can be done first without the (possibly expensive) move out of the FPU: if (x y) return -1; if (x y) return 1; then you can do the doubleToLongBits:

Re: Float/Double compare

2007-07-02 Thread Andrew Haley
Ian Rogers writes: Andrew Haley wrote: We know that any calculation involving NaN returns false, right? So, simple cases can be done first without the (possibly expensive) move out of the FPU: if (x y) return -1; if (x y) return 1;

Re: Float/Double compare

2007-07-01 Thread Mark Wielaard
Hi Ian, On Sat, 2007-06-30 at 15:25 -0400, Ian Rogers wrote: public static int compare(float x, float y) { int ix = floatAsIntBits(x); int iy = floatAsIntBits(y); if (ix == iy) return 0; if (isNaN(x)) return 1; if (isNaN(y)) return -1; int ix_sign = ix31; int iy_sign

Re: Float/Double compare

2007-07-01 Thread Ian Rogers
Hi Mark, Mark Wielaard wrote: Hi Ian, On Sat, 2007-06-30 at 15:25 -0400, Ian Rogers wrote: public static int compare(float x, float y) { int ix = floatAsIntBits(x); int iy = floatAsIntBits(y); if (ix == iy) return 0; if (isNaN(x)) return 1; if (isNaN(y)) return -1; int

Re: Float/Double compare

2007-07-01 Thread Christian Thalinger
On Sat, 2007-06-30 at 16:57 -0400, Ian Rogers wrote: In terms of performance I just tried sorting an array of floats with the new code (floatAsIntBits should have been floatToIntBits, sorry). The test was to initialize an array of floats backwards and then sort it to be ascending. Running a

[cp-patches] Float/Double compare

2007-06-30 Thread Ian Rogers
Attached is a patch that improves the performance of an Float/Double compare by exploiting information carried in their bit integer/long versions sign bit. It removes one comparison from the normal path, as well as making other compares with ints/longs. When sorting an array of floats this can

Re: [cp-patches] Float/Double compare

2007-06-30 Thread Ian Rogers
Andrew Pinski wrote: On 6/30/07, Ian Rogers [EMAIL PROTECTED] wrote: Attached is a patch that improves the performance of an Float/Double compare by exploiting information carried in their bit integer/long versions sign bit. It removes one comparison from the normal path, as well as making

Float/Double compare

2007-06-30 Thread Ian Rogers
Hi everyone, I was tracking a bug and came across the code in Float.compare which is very similar to Double.compare. It just so happened that the bug was being caused by sorting arrays containing lots of floating point 0s. This occurs quite frequently in the Jikes RVM when we have an array of

Re: Float/Double compare

2007-06-30 Thread Ian Rogers
Ian Rogers wrote: public static int compare(float x, float y) { if (isNaN(x)) return isNaN(y) ? 0 : 1; if (isNaN(y)) return -1; // recall that 0.0 == -0.0, so we convert to infinities and try again if (x == 0 y == 0) return (int) (1 / x - 1 / y); if (x ==

Re: Float/Double compare

2007-06-30 Thread Ian Rogers
In terms of performance I just tried sorting an array of floats with the new code (floatAsIntBits should have been floatToIntBits, sorry). The test was to initialize an array of floats backwards and then sort it to be ascending. Running a large enough array and enough iterations to get a ~4