Home / Docs / Diagnostics
U2039: A map, zip_map or update in a function with simd required whose lambda cannot be vectorized for a listed target
Not reported by 0.4.0: reserved for the simd required clause, which this release does not read.
Why Una rejects it
A function of a systems package of edition 0.5 (preview) may require that its loops use the processor's vector instructions, with the clause simd required target neon, avx2 after its ensures clauses: the simd required clause of ADR 0120 rule 58. Every map, zip_map and update with an inline lambda in its body, on a dense value of a float, complex or fixed-width element type, must then be vectorizable for each listed target.
A lambda is vectorizable when:
- its parameters, its captured values and its result have raw types (
F64,F32,I8toU64), and - its body uses only
let, anifon a raw condition, literals, and operators and methods that have a vector instruction on each listed target.
It calls no function, performs no effect and cannot fail. U2039 names the construct, the target and the reason when one is not.
Vectorization never changes a result: the lambda means the scalar loop it equals, and its checks and obligations stay (ADR 0120 rule 55, ADR 0109 rule 5).
The clause lands with its slice of ADR 0120. Until then the release reads no simd required clause, so no program reports U2039, and this text has no example of its own.
How to fix it
- Remove the operation that has no vector instruction from the lambda, such as a call or a float
rem. - Compute it outside the loop.
- Or drop the target that lacks the instruction from the clause.