1  /* Machine description pattern tests.  */
       2  
       3  /* { dg-do compile } */
       4  /* { dg-options "-mmvcle -dP -save-temps" } */
       5  /* { dg-do run { target { s390_useable_hw } } } */
       6  
       7  /* Skip test if -O0 is present on the command line or -O... is missing:
       8  
       9      { dg-skip-if "" { *-*-* } { "-march=z9*" "-O0" } { "" } }
      10      { dg-skip-if "" { *-*-* } { "*" } { "-O*" } }
      11  */
      12  
      13  __attribute__ ((noinline))
      14  void test(char *p, char c, int len)
      15  {
      16    __builtin_memset(p, c, len);
      17  }
      18  
      19  __attribute__ ((noinline))
      20  void test2(char *p, int c, int len)
      21  {
      22    __builtin_memset(p, (char)c, len);
      23  }
      24  
      25  /* Check that the right patterns are used.  */
      26  /* { dg-final { scan-assembler-times {c"?:16:.*{[*]setmem_long_?3?1?z?}} 1 } } */
      27  /* { dg-final { scan-assembler-times {c"?:22:.*{[*]setmem_long_and_?3?1?z?}} 1 } } */
      28  
      29  #define LEN 500
      30  char buf[LEN + 2];
      31  
      32  void init_buf(void)
      33  {
      34    int i;
      35  
      36    buf[0] = 0;
      37    for (i = 1; i <= LEN; i++)
      38      buf[i] = (0x10 + (i & 0x3f));
      39    buf[LEN + 1] = 0x7f;
      40  }
      41  
      42  void validate_buf(char val)
      43  {
      44    int i;
      45  
      46    if (buf[0] != 0)
      47      __builtin_abort();
      48    for (i = 1; i <= LEN; i++)
      49      if (buf[i] != val)
      50        __builtin_abort();
      51    if (buf[LEN + 1] != 0x7f)
      52      __builtin_abort();
      53  }
      54  
      55  int main(void)
      56  {
      57    init_buf();
      58    test(buf + 1, 55, LEN);
      59    validate_buf(55);
      60    init_buf();
      61    test(buf + 1, 66, LEN);
      62    validate_buf(66);
      63  }