Changeset 3985 for trunk/lib_ir


Ignore:
Timestamp:
Aug 9, 2014, 6:18:29 PM (5 years ago)
Author:
linmengl
Message:

add testcases for insert_vector_element and extract_

Location:
trunk/lib_ir/gen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib_ir/gen/llc_func.pytemplate.ll

    r3977 r3985  
    1111}
    1212{% endfor %}
     13
     14{% for x in range(0, 4) %}
     15define <64 x i2> @insertelement_idx0_elt{{ x }}(<64 x i2> %a) {
     16entry:
     17  %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 0
     18  ret <64 x i2> %c
     19}
     20
     21define <64 x i2> @insertelement_idx1_elt{{ x }}(<64 x i2> %a) {
     22entry:
     23  %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 1
     24  ret <64 x i2> %c
     25}
     26
     27define <64 x i2> @insertelement_idx17_elt{{ x }}(<64 x i2> %a) {
     28entry:
     29  %c = insertelement <64 x i2> %a, i2 {{ x }}, i32 17
     30  ret <64 x i2> %c
     31}
     32
     33{% endfor %}
     34
     35{% for x in [0, 1, 17] %}
     36define i8 @extractelement_idx{{ x }}(<64 x i2> %a) {
     37entry:
     38  %c = extractelement <64 x i2> %a, i32 {{ x }}
     39  %d = zext i2 %c to i8
     40  ret i8 %d
     41}
     42{% endfor %}
  • trunk/lib_ir/gen/test_llc.pytemplate.cpp

    r3981 r3985  
    1414  SIMD_type {{ name.c }}(SIMD_type a, SIMD_type b);
    1515{% endfor %}
     16
     17{% for x in range(0, 4) %}
     18  SIMD_type insertelement_idx0_elt{{ x }}(SIMD_type a);
     19  SIMD_type insertelement_idx1_elt{{ x }}(SIMD_type a);
     20  SIMD_type insertelement_idx17_elt{{ x }}(SIMD_type a);
     21{% endfor %}
     22
     23{% for x in [0, 1, 17] %}
     24  short extractelement_idx{{ x }}(SIMD_type a);
     25{% endfor %}
    1626}
    1727
     
    2434int main() {
    2535  SIMD_type a, b, c, d;
     36  short x;
    2637
    2738  for (unsigned i = 0; i < 5; ++i) {
    2839    fill_random(a, b);
    2940
    30   {% for name in FunctionNames %}
     41    {% for name in FunctionNames %}
    3142    {% if name.flag == "" %}
    3243    c = {{ name.c }}(a, b);
     
    3849
    3950    {% endif %}
    40   {% endfor %}
     51    {% endfor %}
    4152
    4253    //Shifting tests need special treatment
    43   {% for name in FunctionNames %}
     54    {% for name in FunctionNames %}
    4455    {% if name.flag == "shifting" %}
    45       {% for x in [0, 1] %}
     56    {% for x in [0, 1] %}
    4657    b = mvmd<2>::fill({{ x }});
    4758    c = {{ name.cxx }}<{{ x }}>(a);
     
    5263    }
    5364
    54       {% endfor %}
     65    {% endfor %}
    5566    {% endif %}
     67    {% endfor %}
     68  }
     69
     70  //Testcases for insert/extract element
     71  {% for x in range(0, 4) %}
     72  a = mvmd<32>::fill4(0, 1, 0, 0);
     73  b = mvmd<32>::fill4(0, 1, 0, {{ x }});
     74  c = insertelement_idx0_elt{{ x }}(a);
     75  if (Store2String(b,1) != Store2String(c,1)) {
     76    cout << "insertelement_idx0_elt{{ x }} failed." << endl;
     77    return 1;
     78  }
     79
     80  b = mvmd<32>::fill4(0, 1, 0, {{ x }} << 2);
     81  c = insertelement_idx1_elt{{ x }}(a);
     82  if (Store2String(b,1) != Store2String(c,1)) {
     83    cout << "insertelement_idx1_elt{{ x }} failed." << endl;
     84    return 1;
     85  }
     86
     87  b = mvmd<32>::fill4(0, 1, {{ x }} << 2, 0);
     88  c = insertelement_idx17_elt{{ x }}(a);
     89  if (Store2String(b,1) != Store2String(c,1)) {
     90    cout << "insertelement_idx17_elt{{ x }} failed." << endl;
     91    return 1;
     92  }
    5693  {% endfor %}
     94
     95  a = mvmd<32>::fill4(0, 1, 0, 3);
     96  x = extractelement_idx0(a);
     97  if (x != 3) {
     98    cout << "extractelement_idx0 failed." << endl;
     99  }
     100
     101  a = mvmd<32>::fill4(0, 1, 0, 3 << 2);
     102  x = extractelement_idx1(a);
     103  if (x != 3) {
     104    cout << "extractelement_idx1 failed." << endl;
     105  }
     106
     107  a = mvmd<32>::fill4(0, 1, 3 << 2, 3);
     108  x = extractelement_idx17(a);
     109  if (x != 3) {
     110    cout << "extractelement_idx17 failed." << endl;
    57111  }
    58112
Note: See TracChangeset for help on using the changeset viewer.