(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
sh/
pr51244-15.c
       1  /* Check that the redundant test removal code in the *cbranch_t split works
       2     as expected.  */
       3  /* { dg-do compile }  */
       4  /* { dg-options "-O2" } */
       5  
       6  /* { dg-final { scan-assembler-not "extu|exts|negc" } } */
       7  /* { dg-final { scan-assembler-times "tst" 6 } } */
       8  
       9  /* { dg-final { scan-assembler-times "movt" 6 { target { ! sh2a } } } } */
      10  /* { dg-final { scan-assembler-times "xor" 3 { target { ! sh2a } } } } */
      11  
      12  /* { dg-final { scan-assembler-times "movt" 3 { target { sh2a } } } } */
      13  /* { dg-final { scan-assembler-times "movrt" 3 { target { sh2a } } } } */
      14  
      15  typedef char bool;
      16  
      17  int
      18  test_0 (int a, int b, int c, int* d)
      19  {
      20    /* non SH2A: 1x tst, 1x movt, 1x xor
      21           SH2A: 1x tst, 1x movrt  */
      22    bool x = a == 0;
      23    d[2] = !x;
      24    return x ? b : c;
      25  }
      26  
      27  int
      28  test_1 (int a, int b, int c, int* d)
      29  {
      30    /* 1x tst, 1x movt  */
      31    bool x = a != 0;
      32    d[2] = !x;
      33    return x ? b : c;
      34  }
      35  
      36  int
      37  test_2 (int a, int b, int c, char* d)
      38  {
      39    /* Check that there is no sign/zero-extension before the store.
      40       non SH2A: 1x tst, 1x movt, 1x xor
      41           SH2A: 1x tst, 1x movrt  */
      42    bool x = a == 0;
      43    d[2] = !x;
      44    return x ? b : c;
      45  }
      46  
      47  int
      48  test_3 (int a, int b, int c, char* d)
      49  {
      50    /* Check that there is no sign/zero-extension before the store.
      51       1x tst, 1x movt  */
      52    bool x = a != 0;
      53    d[2] = !x;
      54    return x ? b : c;
      55  }
      56  
      57  int
      58  test_4 (int a, int b, int c, char* d)
      59  {
      60    /* 1x tst, 1x movt  */
      61    bool x = a != 0;
      62    d[2] = !x;
      63    return !x ? b : c;
      64  }
      65  
      66  int
      67  test_5 (int a, int b, int c, char* d)
      68  {
      69    /* non SH2A: 1x tst, 1x movt, 1x xor
      70           SH2A: 1x tst, 1x movrt  */
      71    bool x = a == 0;
      72    d[2] = !x;
      73    return !x ? b : c;
      74  }