use horizontal rotation helper

This commit is contained in:
Ahmet Inan 2019-09-24 00:07:14 +02:00
commit 969c43f016
2 changed files with 4 additions and 26 deletions

View file

@ -11,6 +11,7 @@ Copyright 2018 Ahmet Inan <inan@aicodix.de>
#include <algorithm>
#include "simd.hh"
#include "rotate.hh"
namespace CODE {
@ -41,6 +42,7 @@ class LDPCDecoder
static const int BNL = (TABLE::LINKS_TOTAL + D-1) / D;
typedef SIMD<int8_t, SIMD_SIZE> TYPE;
Rotate<TYPE, D> rotate;
TYPE bnl[BNL];
TYPE msg[MSG];
@ -95,19 +97,6 @@ class LDPCDecoder
{
return vreinterpret<TYPE>(vand(vmask(b), vorr(vceqz(a), veor(vcgtz(a), vcltz(b)))));
}
static TYPE rotate(TYPE a, int s)
{
if (s < 0)
s += D;
int t = D - s;
TYPE ret;
// TODO: I can has barrel shifter?
for (int n = 0; n < s; ++n)
ret.v[n] = a.v[n+t];
for (int n = 0; n < t; ++n)
ret.v[n+s] = a.v[n];
return ret;
}
bool bad()
{

View file

@ -11,6 +11,7 @@ Copyright 2018 Ahmet Inan <inan@aicodix.de>
#include <algorithm>
#include "simd.hh"
#include "rotate.hh"
namespace CODE {
@ -42,6 +43,7 @@ class LDPCDecoder
static const int POS = (TABLE::LINKS_TOTAL - (2*R-1) + D-1) / D;
typedef SIMD<int8_t, SIMD_SIZE> TYPE;
Rotate<TYPE, D> rotate;
TYPE bnl[BNL];
TYPE msg[MSG];
@ -97,19 +99,6 @@ class LDPCDecoder
{
return vreinterpret<TYPE>(vand(vmask(b), vorr(vceqz(a), veor(vcgtz(a), vcltz(b)))));
}
static TYPE rotate(TYPE a, int s)
{
if (s < 0)
s += D;
int t = D - s;
TYPE ret;
// TODO: I can has barrel shifter?
for (int n = 0; n < s; ++n)
ret.v[n] = a.v[n+t];
for (int n = 0; n < t; ++n)
ret.v[n+s] = a.v[n];
return ret;
}
bool bad()
{