comments & foldmarks to structure the code

Signed-off-by: Matthias Kretz <kretz@kde.org>
simd_cast: implement simdarray to SSE::Vector

This should hopefully cover all cases. The hard ones may be somewhat
inefficent, though using a scalar by scalar copy.

Signed-off-by: Matthias Kretz <kretz@kde.org>
simd_cast: reorder and improve code structure

Signed-off-by: Matthias Kretz <kretz@kde.org>
simd_cast: comments/foldmarkers to structure the code

Signed-off-by: Matthias Kretz <kretz@kde.org>
simd_cast: support offset==0 casts from Scalar to SSE

Signed-off-by: Matthias Kretz <kretz@kde.org>
simd_cast: use generic simdarray code

This code supports more scenarios and thus fixes use of simd_mask_array
with N=3 or N=5

Signed-off-by: Matthias Kretz <kretz@kde.org>
casts test: more sizes to test

Introduced the TEST_TYPES macro to use the same set in all tests

Signed-off-by: Matthias Kretz <kretz@kde.org>
casts test: some cleanup of old code

* there was a useful test that I reenabled
* there still is some code to port to the new test so it
  remains as a comment for now

Signed-off-by: Matthias Kretz <kretz@kde.org>
simd_cast: add foldmarks

Signed-off-by: Matthias Kretz <kretz@kde.org>
simd_cast: documentation + no arg overload + enable_if move

* add new simd_cast that implements cast from nothing (useful for
  generic code that uses variadic templates (empty pack expansion))
* document the two simple simd_cast functions
* move enable_if to return value instead of hidden argument
cast test: test 8->1 casts

* refactored the code slightly so that adding more checks is easier

Signed-off-by: Matthias Kretz <kretz@kde.org>
SSE simd_cast: fix function decl order

the float_v -> (u)short_v cast uses the int_v -> short_v cast, so put
the latter first

Signed-off-by: Matthias Kretz <kretz@kde.org>
cast test: test casts between different impls

in addition to simdarray and default Vc::Vector types also test
Vc::SSE::Vector and Vc::AVX::Vector types for source or destination
types (depending on the available implementations).

The test now needs way too much compile time.

Signed-off-by: Matthias Kretz <kretz@kde.org>
simd_cast: enable AVX optimizations in SSE simd_cast

If AVX is enabled then the SSE types may certainly make use of AVX
instructions/intrinsics. This requires a slightly different include
order to have avx/intrinsics.h included before sse/simd_cast.h

Signed-off-by: Matthias Kretz <kretz@kde.org>
simd_cast: resolve ambiguity

Using braces the compiler might consider the initializer_list overload
(which is ill-formed). Since the internal data constructor is meant it
is better to use parens here.

Signed-off-by: Matthias Kretz <kretz@kde.org>
unittest: smarter typelist support for TEST_TYPES

Now testing for combinations of different types is much easier: There's
a new template type Typelist<...> that can be used as parameter to
TEST_TYPES. Operations for Typelist: concat, outer_product, and
extract_type.

+ support for typeToString<Typelist<...>>()
cast test: split in four executables

The complete cast test is way too huge for the compiler. Compilation
time with GCC can go up to 1h and memory usage is at ~4GB. The number of
possible type casts is extremely large, though. And any of those
conversions can potentially fail, therefore it has to be tested. To make
the test somewhat more manageable I:
* converted the type list arguments to the test functions to type pairs
  of To/From types. Thus, much of the implicit test information (that
  came from a list of destination types internal to the test function)
  is now an explicit test function parameter and visible in the output
  of the test run. This makes the test output a lot more verbose and
  easier to understand.
* split the list of To/From pairs into four parts that are selected via
  a #define. Thus there are four test binaries where there was one
  before. This makes test & development cycles quicker (but still not
  quick enough).
casts test: generic impl + testing random values

* reduced the Vector simd_cast tests to two functions that use variadic
  templates for testing multiple arguments / indexes to simd_cast
* changed the Vector test to not use the same value in all entries and
  thus ensure that the casts correctly keep the vector order.
* additionally test the Vector casts with random numbers
* vim fold markers

Signed-off-by: Matthias Kretz <kretz@kde.org>
fix AVX simd_cast uint_v -> float_v

rounding was off for input values greater than 2^31. The previous
implementation had to round twice (1: cvt; 2: add) which created a
larger jitter. The fix uses cvt to double because the mantissa of double
stores enough bits for the 32-bit integer to get rid of the rounding on
cvt. As inputs greater than 2^31 are not the norm, the function first
tries to live without the extra complexity.

Signed-off-by: Matthias Kretz <kretz@kde.org>
AVX::zeroExtend needs to be safe for clang

clang makes use of the specification that cast128_256 keeps the upper
128 bits uninitialized (like MSVC) and thus requires a propert permute
call that nulls the upper 128 bits.

Signed-off-by: Matthias Kretz <kretz@kde.org>