diff options
author | Adhemerval Zanella <[email protected]> | 2012-11-22 11:55:35 -0600 |
---|---|---|
committer | José Fonseca <[email protected]> | 2012-11-29 11:52:05 +0000 |
commit | 29ba79b2c929ea23b45fa065fe7c9f8fd400210c (patch) | |
tree | 692985c24488e536a0fdaeacc9ca05898119ef74 /src/gallium | |
parent | 43ce9efdbf8c8e1200fe54744820ca2523f36e6b (diff) |
gallivm: clear Altivec NJ bit
This patch enforces the clear of NJ bit in VSCR Altivec register so
denormal numbers are handles as expected by IEEE standards.
Reviewed-by: Roland Scheidegger <[email protected]>
Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_init.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 0065bb49a4b..050eba7b2b3 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -468,6 +468,25 @@ lp_build_init(void) util_cpu_caps.has_avx = 0; } +#ifdef PIPE_ARCH_PPC_64 + /* Set the NJ bit in VSCR to 0 so denormalized values are handled as + * specified by IEEE standard (PowerISA 2.06 - Section 6.3). This garantees + * that some rounding and half-float to float handling does not round + * incorrectly to 0. + */ + if (util_cpu_caps.has_altivec) { + unsigned short mask[] = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, + 0xFFFF, 0xFFFF, 0xFFFE, 0xFFFF }; + __asm ( + "mfvscr %%v1\n" + "vand %0,%%v1,%0\n" + "mtvscr %0" + : + : "r" (*mask) + ); + } +#endif + gallivm_initialized = TRUE; #if 0 |