Home | History | Annotate | Download | only in arm-neon-tests
      1 /*
      2 
      3 Copyright (c) 2009, 2010, 2011 STMicroelectronics
      4 Written by Christophe Lyon
      5 
      6 Permission is hereby granted, free of charge, to any person obtaining a copy
      7 of this software and associated documentation files (the "Software"), to deal
      8 in the Software without restriction, including without limitation the rights
      9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     10 copies of the Software, and to permit persons to whom the Software is
     11 furnished to do so, subject to the following conditions:
     12 
     13 The above copyright notice and this permission notice shall be included in
     14 all copies or substantial portions of the Software.
     15 
     16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     22 THE SOFTWARE.
     23 
     24 */
     25 
     26 #define INSN_NAME vqadd
     27 #define TEST_MSG "VQADD/VQADDQ"
     28 
     29 /* Extra tests for functions requiring types larger than 64 bits to
     30    compute saturation */
     31 void vqadd_64(void);
     32 #define EXTRA_TESTS vqadd_64
     33 
     34 #include "ref_v_binary_sat_op.c"
     35 
     36 void vqadd_64(void)
     37 {
     38   int i;
     39 
     40   DECL_VARIABLE_ALL_VARIANTS(vector1);
     41   DECL_VARIABLE_ALL_VARIANTS(vector2);
     42   DECL_VARIABLE_ALL_VARIANTS(vector_res);
     43 
     44   /* Initialize input "vector1" from "buffer"  */
     45   TEST_MACRO_ALL_VARIANTS_2_5(VLOAD, vector1, buffer);
     46 
     47   VDUP(vector2, , int, s, 64, 1, 0x0);
     48   VDUP(vector2, , uint, u, 64, 1, 0x0);
     49   VDUP(vector2, q, int, s, 64, 2, 0x0);
     50   VDUP(vector2, q, uint, u, 64, 2, 0x0);
     51 
     52   fprintf(ref_file,
     53 	  "\n%s 64 bits saturation cumulative saturation output:\n", TEST_MSG);
     54   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
     55   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
     56   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
     57   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
     58 
     59   fprintf(ref_file, "\n64 bits saturation:\n");
     60   DUMP(TEST_MSG, int, 64, 1, PRIx64);
     61   DUMP(TEST_MSG, uint, 64, 1, PRIx64);
     62   DUMP(TEST_MSG, int, 64, 2, PRIx64);
     63   DUMP(TEST_MSG, uint, 64, 2, PRIx64);
     64 
     65   /* Another set of tests */
     66   VDUP(vector2, , int, s, 64, 1, 0x44);
     67   VDUP(vector2, , uint, u, 64, 1, 0x88);
     68   VDUP(vector2, q, int, s, 64, 2, 0x44);
     69   VDUP(vector2, q, uint, u, 64, 2, 0x88);
     70 
     71   fprintf(ref_file,
     72 	  "\n%s 64 bits saturation cumulative saturation output:\n", TEST_MSG);
     73   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
     74   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
     75   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
     76   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
     77 
     78   DUMP(TEST_MSG, int, 64, 1, PRIx64);
     79   DUMP(TEST_MSG, uint, 64, 1, PRIx64);
     80   DUMP(TEST_MSG, int, 64, 2, PRIx64);
     81   DUMP(TEST_MSG, uint, 64, 2, PRIx64);
     82 
     83   /* Another set of tests */
     84   VDUP(vector2, , int, s, 64, 1, 0x8000000000000003LL);
     85   VDUP(vector2, , uint, u, 64, 1, 0x88);
     86 
     87   VDUP(vector1, q, int, s, 64, 2, 0x4000000000000000LL);
     88   VDUP(vector2, q, int, s, 64, 2, 0x4000000000000000LL);
     89 
     90   VDUP(vector2, q, uint, u, 64, 2, 0x22);
     91 
     92   fprintf(ref_file,
     93 	  "\n%s 64 bits saturation cumulative saturation output:\n", TEST_MSG);
     94   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 64, 1);
     95   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 64, 1);
     96   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 64, 2);
     97   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 64, 2);
     98 
     99   DUMP(TEST_MSG, int, 64, 1, PRIx64);
    100   DUMP(TEST_MSG, uint, 64, 1, PRIx64);
    101   DUMP(TEST_MSG, int, 64, 2, PRIx64);
    102   DUMP(TEST_MSG, uint, 64, 2, PRIx64);
    103 
    104   /* To improve coverage, check saturation with less than 64 bits too */
    105   VDUP(vector2, , int, s, 8, 8, 0x81);
    106   VDUP(vector2, , int, s, 16, 4, 0x8001);
    107   VDUP(vector2, , int, s, 32, 2, 0x80000001);
    108   VDUP(vector2, q, int, s, 8, 16, 0x81);
    109   VDUP(vector2, q, int, s, 16, 8, 0x8001);
    110   VDUP(vector2, q, int, s, 32, 4, 0x80000001);
    111 
    112   fprintf(ref_file, "\nless than 64 bits saturation:\n");
    113   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 8, 8);
    114   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 16, 4);
    115   TEST_BINARY_SAT_OP(INSN_NAME, , int, s, 32, 2);
    116   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 8, 16);
    117   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 16, 8);
    118   TEST_BINARY_SAT_OP(INSN_NAME, q, int, s, 32, 4);
    119 
    120   DUMP(TEST_MSG, int, 8, 8, PRIx8);
    121   DUMP(TEST_MSG, int, 16, 4, PRIx16);
    122   DUMP(TEST_MSG, int, 32, 2, PRIx32);
    123   DUMP(TEST_MSG, int, 8, 16, PRIx8);
    124   DUMP(TEST_MSG, int, 16, 8, PRIx16);
    125   DUMP(TEST_MSG, int, 32, 4, PRIx32);
    126 
    127   VDUP(vector1, , uint, u, 8, 8, 0xF0);
    128   VDUP(vector1, , uint, u, 16, 4, 0xFFF0);
    129   VDUP(vector1, , uint, u, 32, 2, 0xFFFFFFF0);
    130   VDUP(vector1, q, uint, u, 8, 16, 0xF0);
    131   VDUP(vector1, q, uint, u, 16, 8, 0xFFF0);
    132   VDUP(vector1, q, uint, u, 32, 4, 0xFFFFFFF0);
    133 
    134   VDUP(vector2, , uint, u, 8, 8, 0x20);
    135   VDUP(vector2, , uint, u, 16, 4, 0x20);
    136   VDUP(vector2, , uint, u, 32, 2, 0x20);
    137   VDUP(vector2, q, uint, u, 8, 16, 0x20);
    138   VDUP(vector2, q, uint, u, 16, 8, 0x20);
    139   VDUP(vector2, q, uint, u, 32, 4, 0x20);
    140 
    141   fprintf(ref_file,
    142 	  "\n%s less than 64 bits saturation cumulative saturation output:\n",
    143 	  TEST_MSG);
    144   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 8, 8);
    145   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 16, 4);
    146   TEST_BINARY_SAT_OP(INSN_NAME, , uint, u, 32, 2);
    147   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 8, 16);
    148   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 16, 8);
    149   TEST_BINARY_SAT_OP(INSN_NAME, q, uint, u, 32, 4);
    150 
    151   DUMP(TEST_MSG, uint, 8, 8, PRIx8);
    152   DUMP(TEST_MSG, uint, 16, 4, PRIx16);
    153   DUMP(TEST_MSG, uint, 32, 2, PRIx32);
    154   DUMP(TEST_MSG, uint, 8, 16, PRIx8);
    155   DUMP(TEST_MSG, uint, 16, 8, PRIx16);
    156   DUMP(TEST_MSG, uint, 32, 4, PRIx32);
    157 }
    158