Skip to content

Is this Out-of-bounds access? #42

@torshepherd

Description

@torshepherd
version / revision Operating System Compiler & Version Compiler Flags CPU
GCC11 Linux GCC11 -mavx2 -mfma -mavx tigerlake

Testcase

namespace stdx = std::experimental;

static auto indexSimd = stdx::native_simd<int>{[](int i){ return i; }};

stdx::native_simd<int> b;
int a[3]{42, 43, 44};
stdx::where(indexSimd < 3, b).copy_from(a, stdx::element_aligned);

Does this access memory out of bounds? I am pretty sure this code would:

b.copy_from(a, stdx::element_aligned);

But I would expect the former to do a maskload such that it doesn't touch the shadow 4th element?

If this is UB, is there any good way to load a partial SIMD from a contiguous region safely? This would be very valuable for iterating over for example a std::vector of length that is not necessarily divisible by the vector block size

Actual Results

Expected Results

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions