[PATCH] SPU float format: Round towards zero
trevor_smigiel@playstation.sony.com
trevor_smigiel@playstation.sony.com
Mon Aug 4 20:28:00 GMT 2008
Ok for the SPU parts on mainline and 4.3.
Trevor
* Ulrich Weigand <uweigand@de.ibm.com> [2008-08-04 12:30]:
> Hello,
>
> this patch addresses a second feature of SPU single-precision floating-point:
> all operations round towards zero.
>
> I've added a new element of the real_format structure to express this
> property. This is taken into account in round_for_format for the standard
> arithmetic operations, and in builtins.c when choosing the rounding mode
> to use for the MPFR library for compile-time computations.
>
> One problem with always round towards zero is generation of floating-point
> constants like __FLT_MIN__. To ensure that when parsing the decimal
> representation of such constants back in while using round-towards-zero,
> the correct value in the target binary floating-point format results,
> we have to round *away* from zero when generating the decimal value.
>
> This patch fixes this using the method suggested by Joseph Myers here:
> http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00082.html
>
> In addition, it turned out that the SPU back-end didn't always follow
> round-towards-zero itself: for DImode to SFmode conversions, the default
> libgcc routine was used (which implements round-to-nearest). The patch
> adds inline implementations of those conversions that round towards zero,
> as already specified in the SPU Language Extensions specification.
>
> Finally, a number of test cases implicitly (or explicitly) tested
> for the round-to-nearest behavious. This patch also fixes those
> tests to check for round-towards-zero on the SPU.
>
> Tested on spu-elf on mainline and 4.3, fixes the following FAILs:
>
> FAIL: gcc.c-torture/execute/conversion.c execution, -O0
> FAIL: gcc.c-torture/execute/conversion.c execution, -O1
> FAIL: gcc.c-torture/execute/floatunsisf-1.c execution, -O0
> FAIL: gcc.c-torture/execute/floatunsisf-1.c execution, -O1
> FAIL: gcc.c-torture/execute/floatunsisf-1.c execution, -O2
> FAIL: gcc.c-torture/execute/floatunsisf-1.c execution, -O3 -fomit-frame-pointer
> FAIL: gcc.c-torture/execute/floatunsisf-1.c execution, -O3 -g
> FAIL: gcc.c-torture/execute/floatunsisf-1.c execution, -Os
>
> OK to commit?
>
> Bye,
> Ulrich
More information about the Gcc-patches
mailing list