Changeset 4296


Ignore:
Timestamp:
Nov 6, 2014, 6:24:05 PM (4 years ago)
Author:
linmengl
Message:

add tests for long shift right and dslli

Location:
trunk/lib_ir/gen
Files:
3 edited

Legend:

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

    r4278 r4296  
    1717FunctionListI8 = ["add", "sub", "mult", "eq", "lt", "gt", "ult", "ugt", "vsll", "vsrl", "vsra"]
    1818
    19 LongShiftAmount128 = [1,3,5,63,64,65,126,127]
     19LongShiftAmount128 = [1,3,5,63,64,65,126,127, 8,16,24,32,56,120]
    2020LongShiftAmount256 = [1,3,5,63,64,65,127,128,129,191,192,193,254,255]
    2121
  • trunk/lib_ir/gen/llc_func.pytemplate.ll

    r4278 r4296  
    178178 
    179179 
     180{% for sh in LongShiftAmount128 %}
     181define <4 x i32> @long_shift_right_{{sh}}(<4 x i32> %a) {
     182entry:
     183  %aa = bitcast <4 x i32> %a to i128
     184  %c = lshr i128 %aa, {{sh}}
     185  %cc = bitcast i128 %c to <4 x i32>
     186  ret <4 x i32> %cc
     187}
     188{% endfor %}
     189
     190{% for sh in LongShiftAmount128 %}
     191define <4 x i32> @long_shift_dslli_{{sh}}(<4 x i32> %a, <4 x i32> %b) {
     192entry:
     193  %aa = bitcast <4 x i32> %a to i128
     194  %bb = bitcast <4 x i32> %b to i128
     195
     196  %c = shl i128 %aa, {{sh}}
     197  %d = lshr i128 %bb, {{128 - sh}}
     198  %e = or i128 %c, %d
     199
     200  %cc = bitcast i128 %e to <4 x i32>
     201  ret <4 x i32> %cc
     202}
     203{% endfor %}
  • trunk/lib_ir/gen/test_llc.pytemplate.cpp

    r4278 r4296  
    3636{% for sh in LongShiftAmount128 %}
    3737SIMD_type long_shift_left_{{sh}}(SIMD_type a);
     38SIMD_type long_shift_right_{{sh}}(SIMD_type a);
     39SIMD_type long_shift_dslli_{{sh}}(SIMD_type a, SIMD_type b);
    3840{% endfor %}
    3941}
     
    139141}
    140142
    141 int test_long_shift(const SIMD_type &a)
     143int test_long_shift(const SIMD_type &a, const SIMD_type &b)
    142144{
    143   SIMD_type b, c, d;
     145  SIMD_type c, d;
    144146  {% for sh in LongShiftAmount128 %}
    145   b = simd<128>::slli<{{sh}}>(a);
     147  d = simd<128>::slli<{{sh}}>(a);
    146148  c = long_shift_left_{{sh}}(a);
    147   if (to_string(b) != to_string(c)) {
     149  if (to_string(d) != to_string(c)) {
    148150    cout << "long_shift_left with sh = {{sh}} failed." << endl;
    149151    return 1;
    150152  }
    151153
     154  d = simd<128>::srli<{{sh}}>(a);
     155  c = long_shift_right_{{sh}}(a);
     156  if (to_string(d) != to_string(c)) {
     157    cout << "long_shift_right with sh = {{sh}} failed." << endl;
     158    return 1;
     159  }
     160
     161  c = long_shift_dslli_{{sh}}(a, b);
     162  d = simd_or( simd<128>::slli<{{sh}}>(a), simd<128>::srli<{{128 - sh}}>(b) );
     163  if (to_string(c) != to_string(d)) {
     164    cout << "long_shift_dslli with sh = {{sh}} failed." << endl;
     165    return 1;
     166  }
    152167  {% endfor %}
    153168
     
    237252      return 1;
    238253
    239     if (test_long_shift(a))
     254    if (test_long_shift(a, b))
    240255      return 1;
    241256  }
Note: See TracChangeset for help on using the changeset viewer.