Skip to content

[Simd] Introduce broadcast<V>(s) function.

Jö Fahlke requested to merge simd-broadcast-func into test-vc-again

Improve syntax for initializing SIMD vectors: broadcast initialization.

Basically the incantation to broadcast-initialize a SIMD vector is:

V vec(Simd::Scalar<V>(42));

Brace initialization will often not work, and initialization directly by an int will often not work for vectors of floating-point types.

This MR introduces a Simd::broadcast<V>() function, which allows for broadcast initialization like this:

auto vec = Simd::broadcast<V>(42);

The type of the broadcast value does not matter here, as long as it can be explicitly cast to Simd::Scalar<V>. In this sense broadcast<V>() is an explicit-cast function.

Edited by Jö Fahlke

Merge request reports