Changeset 4001 for trunk


Ignore:
Timestamp:
Aug 13, 2014, 5:40:12 PM (5 years ago)
Author:
linmengl
Message:

do exhaust test on insert/extract vector elt on both i2/i4

Location:
trunk/lib_ir/gen
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib_ir/gen/gen.py

    r3997 r4001  
    1313
    1414FunctionListI2 = ["add", "sub", "mult", "eq", "lt", "gt", "ult", "ugt", "vsll", "vsrl", "vsra"]
    15 FunctionListI4 = ["add", "sub", "mult"]
     15FunctionListI4 = ["add", "sub", "mult", "eq", "lt", "gt", "ult", "ugt"]
    1616FunctionListI8 = ["add", "sub", "mult", "eq", "lt", "gt", "ult", "ugt", "vsll", "vsrl", "vsra"]
    1717
  • trunk/lib_ir/gen/llc_func.pytemplate.ll

    r3997 r4001  
    1212{% endfor %}
    1313
    14 {% for i in [0, 1, 17] %}
    15 {% for x in range(0, 4) %}
    16 define <64 x i2> @insertelement_idx{{ i }}_elt{{ x }}(<64 x i2> %a) {
     14define <64 x i2> @insertelement_2(<64 x i2> %a, i8 %elt, i32 %idx) {
    1715entry:
    18   %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 {{ i }}
     16  %e = trunc i8 %elt to i2
     17  %c = insertelement <64 x i2> %a, i2 %e, i32 %idx
    1918  ret <64 x i2> %c
    2019}
    2120
    22 {% endfor %}
    23 {% endfor %}
    24 
    25 {% for x in [0, 1, 17] %}
    26 define i8 @extractelement_idx{{ x }}(<64 x i2> %a) {
     21define i8 @extractelement_2(<64 x i2> %a, i32 %idx) {
    2722entry:
    28   %c = extractelement <64 x i2> %a, i32 {{ x }}
     23  %c = extractelement <64 x i2> %a, i32 %idx
    2924  %d = zext i2 %c to i8
    3025  ret i8 %d
    3126}
    32 {% endfor %}
    3327
    3428; v32i4 starts here
     
    4640{% endfor %}
    4741
     42define <32 x i4> @insertelement_4(<32 x i4> %a, i8 %elt, i32 %idx) {
     43entry:
     44  %e = trunc i8 %elt to i4
     45  %c = insertelement <32 x i4> %a, i4 %e, i32 %idx
     46  ret <32 x i4> %c
     47}
     48
     49define i8 @extractelement_4(<32 x i4> %a, i32 %idx) {
     50entry:
     51  %c = extractelement <32 x i4> %a, i32 %idx
     52  %d = zext i4 %c to i8
     53  ret i8 %d
     54}
     55
    4856; v16i8 starts here
    4957{% for name in FunctionNamesI8 %}
  • trunk/lib_ir/gen/test_llc.pytemplate.cpp

    r3997 r4001  
    1010using namespace std;
    1111{% set Names = FunctionNamesI2 + FunctionNamesI4 + FunctionNamesI8 %}
     12{% set INS_EXT_VEC_ELT_FWs = [2, 4] %}
    1213
    1314extern "C" {
     
    1617{% endfor %}
    1718
    18 {% for x in range(0, 4) %}
    19   SIMD_type insertelement_idx0_elt{{ x }}(SIMD_type a);
    20   SIMD_type insertelement_idx1_elt{{ x }}(SIMD_type a);
    21   SIMD_type insertelement_idx17_elt{{ x }}(SIMD_type a);
    22 {% endfor %}
    23 
    24 {% for x in [0, 1, 17] %}
    25   short extractelement_idx{{ x }}(SIMD_type a);
     19{% for fw in INS_EXT_VEC_ELT_FWs %}
     20  SIMD_type insertelement_{{ fw }}(SIMD_type a, short elt, int idx);
     21  short extractelement_{{ fw }}(SIMD_type a, int idx);
    2622{% endfor %}
    2723}
     
    3531int main() {
    3632  SIMD_type a, b, c, d;
    37   short x;
     33  short x, y;
    3834
    3935  for (unsigned i = 0; i < 50; ++i) {
    4036    fill_random(a, b);
    4137
     38    //All the binary ops
    4239    {% for name in Names %}
    4340    {% if name.flag == "" %}
    44     c = {{ name.c }}(a, b);
    45     d = {{ name.cxx }}(a, b);
    46     if (Store2String(c,1) != Store2String(d,1)) {
    47       cout << "{{ name.c }} faild." << endl;
    48       cout << "A = " << Store2String(a, 1) << endl;
    49       cout << "B = " << Store2String(b, 1) << endl;
    50       cout << "c = " << Store2String(c, 1) << endl;
    51       cout << "cxx=" << Store2String(d, 1) << endl;
     41      c = {{ name.c }}(a, b);
     42      d = {{ name.cxx }}(a, b);
     43      if (Store2String(c,1) != Store2String(d,1)) {
     44        cout << "{{ name.c }} faild." << endl;
     45        cout << "A = " << Store2String(a, 1) << endl;
     46        cout << "B = " << Store2String(b, 1) << endl;
     47        cout << "c = " << Store2String(c, 1) << endl;
     48        cout << "cxx=" << Store2String(d, 1) << endl;
    5249
    53       return 1;
    54     }
     50        return 1;
     51      }
    5552
    5653    {% endif %}
     
    6158    {% if name.flag == "shifting" %}
    6259    {% for x in range(0, name.fw) %}
    63     c = {{ name.cxx }}<{{ x }}>(a);
    64     b = mvmd<{{ name.fw }}>::fill({{ x }});
    65     d = {{ name.c }}(a, b);
    66     if (Store2String(c,1) != Store2String(d,1)) {
    67       cout << "{{ name.c }} faild." << endl;
    68       return 1;
    69     }
     60      c = {{ name.cxx }}<{{ x }}>(a);
     61      b = mvmd<{{ name.fw }}>::fill({{ x }});
     62      d = {{ name.c }}(a, b);
     63      if (Store2String(c,1) != Store2String(d,1)) {
     64        cout << "{{ name.c }} faild." << endl;
     65        return 1;
     66      }
    7067
    7168    {% endfor %}
    7269    {% endif %}
    7370    {% endfor %}
    74   }
    7571
    76   //Testcases for insert/extract element on v64i2
    77   {% for x in range(0, 4) %}
    78   a = mvmd<32>::fill4(0, 1, 0, 0);
    79   b = mvmd<32>::fill4(0, 1, 0, {{ x }});
    80   c = insertelement_idx0_elt{{ x }}(a);
    81   if (Store2String(b,1) != Store2String(c,1)) {
    82     cout << "insertelement_idx0_elt{{ x }} failed." << endl;
    83     return 1;
    84   }
     72    //insert_vector_elt and extract_
     73    {% for fw in INS_EXT_VEC_ELT_FWs %}
     74    {% for idx in range(0, 128 // fw) %}
     75      x = extractelement_{{ fw }}(a, {{ idx }});
     76      y = mvmd<{{ fw }}>::extract<{{ idx }}>(a);
     77      if (x != y) {
     78        cout << "extractelement_{{fw}} failed." << endl;
     79        return 1;
     80      }
    8581
    86   b = mvmd<32>::fill4(0, 1, 0, {{ x }} << 2);
    87   c = insertelement_idx1_elt{{ x }}(a);
    88   if (Store2String(b,1) != Store2String(c,1)) {
    89     cout << "insertelement_idx1_elt{{ x }} failed." << endl;
    90     return 1;
    91   }
    92 
    93   b = mvmd<32>::fill4(0, 1, {{ x }} << 2, 0);
    94   c = insertelement_idx17_elt{{ x }}(a);
    95   if (Store2String(b,1) != Store2String(c,1)) {
    96     cout << "insertelement_idx17_elt{{ x }} failed." << endl;
    97     return 1;
    98   }
    99   {% endfor %}
    100 
    101   a = mvmd<32>::fill4(0, 1, 0, 3);
    102   x = extractelement_idx0(a);
    103   if (x != 3) {
    104     cout << "extractelement_idx0 failed." << endl;
    105   }
    106 
    107   a = mvmd<32>::fill4(0, 1, 0, 3 << 2);
    108   x = extractelement_idx1(a);
    109   if (x != 3) {
    110     cout << "extractelement_idx1 failed." << endl;
    111   }
    112 
    113   a = mvmd<32>::fill4(0, 1, 3 << 2, 3);
    114   x = extractelement_idx17(a);
    115   if (x != 3) {
    116     cout << "extractelement_idx17 failed." << endl;
     82      x = rand() % 100;
     83      c = insertelement_{{ fw }}(a, x, {{ idx }});
     84      d = mvmd<{{ fw }}>::insert<{{ idx }}>(a, x);
     85      if (Store2String(c,1) != Store2String(d,1)) {
     86        cout << "insertelement_{{fw}} failed." << endl;
     87        return 1;
     88      }
     89    {% endfor %}
     90    {% endfor %}
    11791  }
    11892
Note: See TracChangeset for help on using the changeset viewer.