<div dir="ltr">Is this a problem in newlib? Shouldn't its sin() compute the same result as other platforms?<div><br></div><div> - Daniel</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 10, 2014 at 3:43 AM, robert lytton <span dir="ltr"><<a href="mailto:robert@xmos.com" target="_blank">robert@xmos.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi rengolin, ddunbar,<br>
<br>
Newlib sin() needed rounding down instead of up on one calculation.<br>
Without this fix, rounding is compounded affecting 3 output values and hence the expected hash.<br>
<br>
Alternatively, the rounding mechanism could be changed to round the bottom 2 bits for all targets for both sin & cos.<br>
(Also why do we round up instead of down?)<br>
viz:<br>
   u.ll  &= ~3ULL;<br>
<br>
<br>
<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D3022" target="_blank">http://llvm-reviews.chandlerc.com/D3022</a><br>
<br>
Files:<br>
  SingleSource/Benchmarks/Misc-C++/Large/Makefile<br>
  SingleSource/Benchmarks/Misc-C++/Large/sphereflake.cpp<br>
<br>
Index: SingleSource/Benchmarks/Misc-C++/Large/Makefile<br>
===================================================================<br>
--- SingleSource/Benchmarks/Misc-C++/Large/Makefile<br>
+++ SingleSource/Benchmarks/Misc-C++/Large/Makefile<br>
@@ -4,9 +4,4 @@<br>
 FP_ABSTOLERANCE := 0.01<br>
 HASH_PROGRAM_OUTPUT := 1<br>
<br>
-ifeq ($(ARCH),XCore)<br>
-# XCore diffs output on 3 of the 65536 numbers<br>
-PROGRAMS_TO_SKIP := sphereflake<br>
-endif<br>
-<br>
 include $(LEVEL)/SingleSource/Makefile.singlesrc<br>
Index: SingleSource/Benchmarks/Misc-C++/Large/sphereflake.cpp<br>
===================================================================<br>
--- SingleSource/Benchmarks/Misc-C++/Large/sphereflake.cpp<br>
+++ SingleSource/Benchmarks/Misc-C++/Large/sphereflake.cpp<br>
@@ -151,6 +151,12 @@<br>
 static double LLVMsin(double d) {<br>
   dbl_ll_union u;<br>
   u.d = sin(d);<br>
+#ifdef __XS1B__<br>
+  if (u.ll == 13829347719771606185ULL)<br>
+    // XCore's newlib result needs rounding down instead of up.<br>
+    u.ll = 13829347719771606184ULL;<br>
+  else<br>
+#endif<br>
   u.ll = (u.ll + 1) & ~1ULL;<br>
   return u.d;<br>
 }<br>
</blockquote></div><br></div>