1  /* { dg-require-effective-target vect_int } */
       2  
       3  #include "tree-vect.h"
       4  
       5  #define N 32
       6  
       7  extern void abort (void);
       8  typedef unsigned short T;
       9  
      10  __attribute__ ((noinline)) void
      11  testmax (const T *c, T init, T result)
      12  {
      13    T lc[N], accum = init;
      14    int i;
      15  
      16    __builtin_memcpy (lc, c, sizeof(lc));
      17  
      18    for (i = 0; i < N; i++) {
      19      accum = accum < lc[i] ? lc[i] : accum;
      20    }
      21  
      22    if (accum != result)
      23      abort ();
      24  }
      25  
      26  __attribute__ ((noinline)) void
      27  testmin (const T *c, T init, T result)
      28  {
      29    T lc[N], accum = init;
      30    int i;
      31  
      32    __builtin_memcpy (lc, c, sizeof(lc));
      33  
      34    for (i = 0; i < N; i++) {
      35      accum = accum > lc[i] ? lc[i] : accum;
      36    }
      37  
      38    if (accum != result)
      39      abort ();
      40  }
      41  
      42  int main (void)
      43  { 
      44    static unsigned short const A[N] = {
      45      0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
      46      0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010,
      47      0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
      48      0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff
      49    };
      50  
      51    static unsigned short const B[N] = {
      52      0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
      53      0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff,
      54      0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007,
      55      0x8008, 0x8009, 0x800a, 0x800b, 0x800c, 0x800d, 0x800e, 0x800f
      56    };
      57  
      58    static unsigned short const C[N] = {
      59      0xffff, 0xfffe, 0xfffd, 0xfffc, 0xfffb, 0xfffa, 0xfff9, 0xfff8,
      60      0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010,
      61      0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007,
      62      0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
      63    };
      64  
      65    check_vect ();
      66    
      67    testmin (A, 10, 1);
      68    testmin (B, 0x7fff, 0x7000);
      69    testmin (C, 0x7fff, 0x0009);
      70  
      71    testmax (A, 0, 0x7fff);
      72    testmax (B, 0, 0x800f);
      73    testmax (C, 0, 0xffff);
      74  
      75    return 0;
      76  }
      77