1279264Sdelphij/* { dg-do run } */
2110010Smarkm/* { dg-options "-O2 -ffast-math -msse -mfpmath=sse -mrecip" } */
3110010Smarkm/* { dg-require-effective-target sse } */
4160819Ssimon#include "sse-check.h"
5110010Smarkm
6110010Smarkmextern float sqrtf (float);
7110010Smarkmfloat __attribute__((noinline)) broken (float a, float b)
8110010Smarkm{
9110010Smarkm  return sqrtf (a / b);
10110010Smarkm}
11110010Smarkm
12110010Smarkmextern void abort (void);
13110010Smarkmextern void *memcpy (void *, const void *, __SIZE_TYPE__);
14110010Smarkmstatic void
15110010Smarkmsse_test (void)
16110010Smarkm{
17110010Smarkm  int i;
18110010Smarkm  float x;
19110010Smarkm  char buf[sizeof (float)];
20215698Ssimon  x = broken (0.0f, 10000.0f);
21215698Ssimon  /* A convoluted way to check for the correct result (zero) for all
22215698Ssimon     floating point formats.
23215698Ssimon     We can't use ==, !=, or range checks, or isinf/isnan/isunordered,
24215698Ssimon     because all of these will not do the right thing under -ffast-math,
25110010Smarkm     as they can assume that neither nan nor inf are returned.  */
26110010Smarkm  memcpy (&buf, &x, sizeof (float));
27110010Smarkm  for (i = 0; i < sizeof (float); i++)
28110010Smarkm    if (buf[i] != 0)
29110010Smarkm      abort ();
30110010Smarkm}
31110010Smarkm