Home | History | Annotate | Download | only in x86
      1 
      2 /* Marginally test fprem/fprem1/fsincos; these are hard to check
      3    otherwise since compilers hardly ever generate them. */
      4 
      5 #include <stdio.h>
      6 
      7 double do_fprem ( void )
      8 {
      9   double res;
     10   __asm__ __volatile__(
     11     "ffree %%st(0)\n\t"
     12     "ffree %%st(1)\n\t"
     13     "fldpi\n\t"
     14     "fldln2\n\t"
     15     "fprem\n\t"
     16     "fstpl 0(%0)"
     17     : : "r"(&res)
     18   );
     19   return res;
     20 }
     21 
     22 double do_fprem1 ( void )
     23 {
     24   double res;
     25   __asm__ __volatile__(
     26     "ffree %%st(0)\n\t"
     27     "ffree %%st(1)\n\t"
     28     "fldpi\n\t"
     29     "fldln2\n\t"
     30     "fprem1\n\t"
     31     "fstpl 0(%0)"
     32     : : "r"(&res)
     33   );
     34   return res;
     35 }
     36 
     37 double do_fsincos ( void )
     38 {
     39   double res;
     40   __asm__ __volatile__(
     41     "fldln2\n\t"
     42     "fsincos\n\t"
     43     "fsub %%st(1)\n\t"
     44     "fstpl 0(%0)"
     45     : : "r"(&res)
     46   );
     47   return res;
     48 }
     49 
     50 int main ( void )
     51 {
     52   __asm__ __volatile__("finit");
     53   printf("fprem   %f\n", do_fprem());
     54   printf("fprem1  %f\n", do_fprem1());
     55   printf("fsincos %f\n", do_fsincos());
     56   return 0;
     57 }
     58