|
From: <sv...@va...> - 2016-10-12 14:16:17
|
Author: petarj
Date: Wed Oct 12 15:16:08 2016
New Revision: 16038
Log:
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.
Modified:
trunk/none/tests/mips32/round.c
trunk/none/tests/mips64/round.c
trunk/none/tests/mips64/rounding_mode.h
Modified: trunk/none/tests/mips32/round.c
==============================================================================
--- trunk/none/tests/mips32/round.c (original)
+++ trunk/none/tests/mips32/round.c Wed Oct 12 15:16:08 2016
@@ -149,12 +149,24 @@
}
}
+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 @@
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:
Modified: trunk/none/tests/mips64/round.c
==============================================================================
--- trunk/none/tests/mips64/round.c (original)
+++ trunk/none/tests/mips64/round.c Wed Oct 12 15:16:08 2016
@@ -9,6 +9,7 @@
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 @@
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:
Modified: trunk/none/tests/mips64/rounding_mode.h
==============================================================================
--- trunk/none/tests/mips64/rounding_mode.h (original)
+++ trunk/none/tests/mips64/rounding_mode.h Wed Oct 12 15:16:08 2016
@@ -60,4 +60,15 @@
break;
}
}
+
+void clear_fcc(){
+ __asm__ __volatile__(
+ "cfc1 $t0, $31" "\n\t"
+ "and $t0, $t0, 0x17FFFFF" "\n\t"
+ "ctc1 $t0, $31" "\n\t"
+ :
+ :
+ : "t0"
+ );
+}
#endif
|