1  /* Check that on SH2A the 4 byte movu.b and movu.w displacement insns are
       2     generated.  This has to be checked with -O2 because some of the patterns
       3     rely on peepholes.  */
       4  /* { dg-do compile { target { sh2a } } }  */
       5  /* { dg-options "-O2" } */
       6  /* { dg-final { scan-assembler-times "movu.b" 4 } } */
       7  /* { dg-final { scan-assembler-times "movu.w" 3 } } */
       8  
       9  int
      10  test_00 (unsigned char* x)
      11  {
      12    /* 1x movu.b  */
      13    return x[0];
      14  }
      15  
      16  int
      17  test_01 (unsigned short* x)
      18  {
      19    /* 1x movu.w  */
      20    return x[0];
      21  }
      22  
      23  int
      24  test_02 (unsigned char* x)
      25  {
      26    /* 1x movu.b  */
      27    return x[1];
      28  }
      29  
      30  int
      31  test_03 (unsigned char* x)
      32  {
      33    /* 1x movu.b  */
      34    return x[32];
      35  }
      36  
      37  int
      38  test_04 (unsigned char* x)
      39  {
      40    /* 1x movu.b  */
      41    return x[9000];
      42  }
      43  
      44  int
      45  test_05 (unsigned short* x)
      46  {
      47    /* 1x movu.w  */
      48    return x[9000];
      49  }
      50  
      51  int
      52  test_06 (unsigned char* x, int i)
      53  {
      54    /* No movu.b expected here.  Should use mov.b (r0,r4) + extu.b instead.  */
      55    return x[i];
      56  }
      57  
      58  int
      59  test_07 (unsigned short* x, int i)
      60  {
      61    /* No movu.w expected here.  Should use mov.w (r0,r4) + extu.w instead.  */
      62    return x[i];
      63  }
      64  
      65  int
      66  test_08 (unsigned char* x, int c)
      67  {
      68    /* No movu.b expected here.  Should use post-inc addressing instead.  */
      69    int s = 0;
      70    int i;
      71    for (i = 0; i < c; ++i)
      72      s += x[i];
      73    return s;
      74  }
      75  
      76  void
      77  test_09 (unsigned char* x, unsigned char* y)
      78  {
      79    /* No movu.b expected here, since the zero-extension is irrelevant.  */
      80    x[1] = y[1];
      81    x[2] = y[2];
      82  }
      83  
      84  void
      85  test_10 (unsigned char* x, unsigned short* y)
      86  {
      87    /* No movu.w expected here, since the zero-extension is irrelevant.  */
      88    x[1] = y[1];
      89    x[2] = y[2];
      90  }
      91  
      92  int
      93  test_11 (unsigned char* x, unsigned short* y)
      94  {
      95    /* 1x movu.w  */
      96    int yy = y[1];
      97    x[1] = yy;
      98    return yy;
      99  }