1  /* Verify that the fsca input value is not converted to float and then back
       2     to int.  Notice that we can't count just "lds" insns because mode switches
       3     use "lds.l".  */
       4  /* { dg-do compile { target { has_fsca } } }  */
       5  /* { dg-options "-O2 -mfsca -funsafe-math-optimizations -fno-ipa-icf" }  */
       6  /* { dg-final { scan-assembler-times "fsca" 7 } } */
       7  /* { dg-final { scan-assembler-times "shad" 1 } } */
       8  /* { dg-final { scan-assembler-times "lds\tr\[0-9\],fpul" 6 } } */
       9  /* { dg-final { scan-assembler-times "fmul" 2 } } */
      10  /* { dg-final { scan-assembler-times "ftrc" 1 } } */
      11  
      12  #include <math.h>
      13  
      14  static const float pi = 3.14159265359f;
      15  
      16  float
      17  test00 (int x)
      18  {
      19    /* 1x shad, 1x lds, 1x fsca  */
      20    return sinf ( (x >> 8) * (2*pi) / (1 << 16));
      21  }
      22  
      23  float
      24  test01 (int x)
      25  {
      26    /* 1x lds, 1x fsca  */
      27    return sinf (x * (2*pi) / 65536);
      28  }
      29  
      30  float
      31  test02 (int x)
      32  {
      33    /* 1x lds, 1x fsca  */
      34    return sinf (x * (2*pi / 65536));
      35  }
      36  
      37  float
      38  test03 (int x)
      39  {
      40    /* 1x lds, 1x fsca  */
      41    float scale = 2*pi / 65536;
      42    return sinf (x * scale);
      43  }
      44  
      45  float
      46  test04 (int x)
      47  {
      48    /* 1x lds, 1x fsca  */
      49    return cosf (x / 65536.0f * 2*pi);
      50  }
      51  
      52  float
      53  test05 (int x)
      54  {
      55    /* 1x lds, 1x fsca, 1x fmul  */
      56    float scale = 2*pi / 65536;
      57    return sinf (x * scale) * cosf (x * scale);
      58  }
      59  
      60  float
      61  test_06 (float x)
      62  {
      63    /* 1x fmul, 1x ftrc, 1x fsca  */
      64    return sinf (x);
      65  }