diff mbox series

[testsuite,alpha] : Add testcase for glibc sqrt bug

Message ID CAFULd4ZC3aj9-5k3H8aq_THs7rFiJKaD9niWCb9YVEAW2of8Og@mail.gmail.com
State New
Headers show
Series [testsuite,alpha] : Add testcase for glibc sqrt bug | expand

Commit Message

Uros Bizjak Nov. 1, 2017, 7:50 a.m. UTC
The testcase for an alpha glibc bug [1] that bit us again.

2017-11-01  Uros Bizjak  <ubizjak@gmail.com>

    * gcc.target/alpha/sqrt.c: New test.

Tested on alphaev68-linux-gnu, committed to mainline SVN.

[1] https://sourceware.org/ml/libc-alpha/2017-04/msg00256.html

Uros.
diff mbox series

Patch

Index: gcc.target/alpha/sqrt.c
===================================================================
--- gcc.target/alpha/sqrt.c	(nonexistent)
+++ gcc.target/alpha/sqrt.c	(working copy)
@@ -0,0 +1,25 @@ 
+/* glibc bug, https://sourceware.org/ml/libc-alpha/2017-04/msg00256.html
+   When using software completions, we have to prevent assembler to match
+   input and output operands of sqrtt/sqrtf insn.  Fixed in glibc 2.26.  */
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-builtin-sqrt -mieee" } */
+
+double sqrt (double);
+
+static double
+float64frombits (unsigned long b)
+{
+  union { unsigned long __b; double __d; } u = { .__b = b };
+  return u.__d;
+}
+
+int
+main (void)
+{
+  double a = float64frombits (2);
+
+  if (sqrt (a) != 3.1434555694052576e-162)
+    __builtin_abort ();
+
+  return 0;
+}