1  /* Check that addc and subc instructions are generated as expected in
       2     combination with ifcvt.  */
       3  /* { dg-do compile }  */
       4  /* { dg-options "-O2" }  */
       5  
       6  /* { dg-final { scan-assembler-times "subc" 4 { target { ! sh2a } } } }  */
       7  /* { dg-final { scan-assembler-times "addc" 4 { target { ! sh2a } } } }  */
       8  /* { dg-final { scan-assembler-times "not\t" 0 { target { ! sh2a } } } }  */
       9  
      10  /* { dg-final { scan-assembler-times "subc" 4 { target { sh2a } } } }  */
      11  /* { dg-final { scan-assembler-times "addc" 4 { target { sh2a } } } }  */
      12  /* { dg-final { scan-assembler-times "nott" 0 { target { sh2a } } } }  */
      13  
      14  /* { dg-final { scan-assembler-times "tst\t" 4 } }  */
      15  /* { dg-final { scan-assembler-times "cmp/eq" 1 } }  */
      16  /* { dg-final { scan-assembler-times "cmp/pl" 2 } }  */
      17  /* { dg-final { scan-assembler-times "cmp/gt" 1 } }  */
      18  
      19  /* { dg-final { scan-assembler-not "movt" } }  */
      20  /* { dg-final { scan-assembler-not "negc" } }  */
      21  /* { dg-final { scan-assembler-not "movrt" } }  */
      22  
      23  int
      24  test_00 (int x, int y)
      25  {
      26    /* 1x tst, 1x subc  */
      27    if (y)
      28      ++x;
      29    return x;
      30  }
      31  
      32  int
      33  test_01 (int x, int y)
      34  {
      35    /* 1x tst, 1x addc  */
      36    if (y)
      37      --x;
      38    return x;
      39  }
      40  
      41  int
      42  test_02 (int x, int y)
      43  {
      44    /* 1x tst, 1x addc  */
      45    if (!y)
      46      ++x;
      47    return x;
      48  }
      49  
      50  int
      51  test_03 (int x, int y)
      52  {
      53    /* 1x tst, 1x subc  */
      54    if (!y)
      55      --x;
      56    return x;
      57  }
      58  
      59  int
      60  test_04 (int x, int y)
      61  {
      62    /* 1x cmp/eq, 1x addc  */
      63    if (y == x)
      64      ++x;
      65    return x;
      66  }
      67  
      68  int
      69  test_05 (int x, int y)
      70  {
      71    /* 1x cmp/gt, 1x subc  */
      72    if (y < 4)
      73      ++x;
      74    return x;
      75  }
      76  
      77  int
      78  test_06 (int x)
      79  {
      80    /* 1x cmp/pl, 1x addc  */
      81    return x > 0 ? x + 1 : x;
      82  }
      83  
      84  int
      85  test_07 (int x)
      86  {
      87    /* 1x cmp/pl, 1x subc  */
      88    return x > 0 ? x - 1 : x;
      89  }