(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
vsx-vector-abss.c
       1  /* { dg-do run } */
       2  /* { dg-skip-if "" { powerpc*-*-darwin* } } */
       3  /* { dg-require-effective-target vsx_hw } */
       4  /* { dg-options "-mvsx -O2" } */
       5  
       6  
       7  #include <altivec.h>
       8  #include <stdlib.h>
       9  
      10  #ifdef DEBUG
      11  #include <stdio.h>
      12  #endif
      13  
      14  void abort (void);
      15  
      16  static vector signed char
      17  vabss_char (vector signed char arg)
      18  {
      19    return vec_abss (arg);
      20  }
      21  
      22  static vector signed short
      23  vabss_short (vector signed short arg)
      24  {
      25    return vec_abss (arg);
      26  }
      27  
      28  static vector signed int
      29  vabss_int (vector signed int arg)
      30  {
      31    return vec_abss (arg);
      32  }
      33  
      34  int
      35  main (int argc, char *argv[])
      36  {
      37    int i;
      38    vector signed char val_char;
      39    vector signed char expected_char;
      40    vector signed char result_char;
      41    vector signed short val_short;
      42    vector signed short expected_short;
      43    vector signed short result_short;
      44    vector signed int val_int;
      45    vector signed int expected_int;
      46    vector signed int result_int;
      47  
      48    /* CHAR */
      49    val_char = (vector signed char) {-7, 6, -5, 4, -3, 1, 0, -0, 1, -2, 3, -5, 6, -7};
      50    expected_char = (vector signed char) {7, 6, 5, 4, 3, 1, 0, 0, 1, 2, 3, 5, 6, 7};
      51  
      52    result_char = vabss_char (val_char);
      53  
      54    for (i = 0; i< 16; i++)
      55      if (result_char[i] != expected_char[i])
      56  #ifdef DEBUG
      57        printf("ERROR: vec_abss() result_char[%d] = %d, not expected_char[%d] = %d\n",
      58  	      i, result_char[i], i, expected_char[i]);
      59  #else
      60        abort ();
      61  #endif
      62  
      63    /* SHORT */
      64    val_short = (vector signed short) {-0, 1, -2, 3, 4, -5, 6, -7};
      65    expected_short = (vector signed short) {0, 1, 2, 3, 4, 5, 6, 7};
      66  
      67    result_short = vabss_short (val_short);
      68  
      69    for (i = 0; i< 8; i++)
      70      if (result_short[i] != expected_short[i])
      71  #ifdef DEBUG
      72        printf("ERROR: vec_abss() result_short[%d] = %d, not expected_short[%d] = %d\n",
      73  	      i, result_short[i], i, expected_short[i]);
      74  #else
      75        abort ();
      76  #endif
      77  
      78    /* INT */
      79    val_int = (vector signed int) {-7, 6, -5, 4};
      80    expected_int = (vector signed int) {7, 6, 5, 4};
      81  
      82    result_int = vabss_int (val_int);
      83  
      84    for (i = 0; i< 4; i++) 
      85      if (result_int[i] != expected_int[i])
      86  #ifdef DEBUG
      87        printf("ERROR: vec_abss() result_int[%d] = %d, not expected_int[%d] = %d\n",
      88  	      i, result_int[i], i, expected_int[i]);
      89  #else
      90        abort ();
      91  #endif
      92        
      93    return 0;
      94  }
      95  
      96