From: Petar Jovanovic Date: Wed, 12 Oct 2016 14:16:08 +0000 (+0000) Subject: mips: clear fcc bits in fcsr after calling printf() X-Git-Tag: svn/VALGRIND_3_13_0~343 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=517d43c27820c2cba0e79ab856a021943cdf4226;p=thirdparty%2Fvalgrind.git mips: clear fcc bits in fcsr after calling printf() Clear floating point condition codes in the test after calling external function (in this case printf), as it might have clobbered fcc bits in fcsr. This resolves none/tests/mips64/round.c failure on some systems. Patch by Aleksandra Karadzic. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@16038 --- diff --git a/none/tests/mips32/round.c b/none/tests/mips32/round.c index 310dd367c1..710c15adea 100644 --- a/none/tests/mips32/round.c +++ b/none/tests/mips32/round.c @@ -149,12 +149,24 @@ void set_rounding_mode(round_mode_t mode) } } +void clear_fcc(){ + __asm__ __volatile__( + "cfc1 $t0, $31" "\n\t" + "and $t0, $t0, 0x17FFFFF" "\n\t" + "ctc1 $t0, $31" "\n\t" + : + : + : "t0" + ); +} + int directedRoundingMode(flt_dir_op_t op) { int fd_w = 0; int i; int fcsr = 0; round_mode_t rm = TO_NEAREST; for (i = 0; i < 24; i++) { + clear_fcc(); set_rounding_mode(rm); switch(op) { case CEILWS: @@ -217,6 +229,7 @@ int FCSRRoundingMode(flt_round_op_t op1) set_rounding_mode(rm); printf("roundig mode: %s\n", round_mode_name[rm]); for (i = 0; i < 24; i++) { + clear_fcc(); set_rounding_mode(rm); switch(op1) { case CVTDS: diff --git a/none/tests/mips64/round.c b/none/tests/mips64/round.c index e46c7b6fae..4634057190 100644 --- a/none/tests/mips64/round.c +++ b/none/tests/mips64/round.c @@ -9,6 +9,7 @@ int directedRoundingMode(flt_dir_op_t op) { int i; int fcsr = 0; for (i = 0; i < MAX_ARR; i++) { + clear_fcc(); switch(op) { case CEILWS: UNOPfw("ceil.w.s"); @@ -111,6 +112,7 @@ int FCSRRoundingMode(flt_round_op_t op1) set_rounding_mode(rm); printf("roundig mode: %s\n", round_mode_name[rm]); for (i = 0; i < MAX_ARR; i++) { + clear_fcc(); set_rounding_mode(rm); switch(op1) { case CVTDS: diff --git a/none/tests/mips64/rounding_mode.h b/none/tests/mips64/rounding_mode.h index 38354be9dd..c42cb340c5 100644 --- a/none/tests/mips64/rounding_mode.h +++ b/none/tests/mips64/rounding_mode.h @@ -60,4 +60,15 @@ void set_rounding_mode(round_mode_t mode) break; } } + +void clear_fcc(){ + __asm__ __volatile__( + "cfc1 $t0, $31" "\n\t" + "and $t0, $t0, 0x17FFFFF" "\n\t" + "ctc1 $t0, $31" "\n\t" + : + : + : "t0" + ); +} #endif