[llvm-commits] [test-suite] r115714 - /test-suite/trunk/SingleSource/Regression/C/uint64_to_float.c

Owen Anderson resistor at mac.com
Tue Oct 5 16:29:43 PDT 2010


Author: resistor
Date: Tue Oct  5 18:29:43 2010
New Revision: 115714

URL: http://llvm.org/viewvc/llvm-project?rev=115714&view=rev
Log:
Use __floatundisf from libgcc and/or compiler_rt as the canonical reference for the uint64->float conversion, so that
this doesn't trivially pass by comparing the compiler against itself.  Unfortunately, __floatundisf only supports
round-to-nearest rounding modes, so disable the other modes for now.  Steve is hoping to provide a canonical reference
converter for all rounding modes.

Modified:
    test-suite/trunk/SingleSource/Regression/C/uint64_to_float.c

Modified: test-suite/trunk/SingleSource/Regression/C/uint64_to_float.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/Regression/C/uint64_to_float.c?rev=115714&r1=115713&r2=115714&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/Regression/C/uint64_to_float.c (original)
+++ test-suite/trunk/SingleSource/Regression/C/uint64_to_float.c Tue Oct  5 18:29:43 2010
@@ -14,14 +14,11 @@
 // We test in all four basic rounding modes, to further flush out any
 // double-rounding issues, or behavior at zero.
 
-float convert(uint64_t x) {
-  return (float)x;
-}
-
+extern float __floatundisf(uint64_t);
 void test(uint64_t x) {
     union floatbits { uint32_t x; float f; };
-	const union floatbits expected = { .f = x };
-	const union floatbits observed = { .f = convert(x) };
+	const union floatbits expected = { .f = __floatundisf(x) };
+	const union floatbits observed = { .f = x };
     
 	if (expected.x != observed.x) {
 		printf("Error detected @ 0x%016llx\n", x);
@@ -34,13 +31,14 @@
   int i, j, k, l, m;
 	const uint64_t one = 1;
 	const uint64_t mone = -1;
-
-    const int roundingModes[4] = { FE_TONEAREST,
-        FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO };
+    
+    // FIXME: Other rounding modes are temporarily disabled until we have
+    // a canonical source to compare against.
+    const int roundingModes[4] = { FE_TONEAREST };
     const char *modeNames[4] = {"to nearest", "down", "up", "towards zero"};
     
     for ( m=0; m<4; ++m) {
-        fesetround(roundingModes[m]);
+        fesetround(roundingModes[0]);
         printf("Testing uint64_t --> float conversions in round %s...\n",
                modeNames[m]);
     





More information about the llvm-commits mailing list