Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vector comparisons should not have result type bool #2884

Closed
andersfr opened this issue Jul 13, 2019 · 3 comments
Closed

Vector comparisons should not have result type bool #2884

andersfr opened this issue Jul 13, 2019 · 3 comments
Milestone

Comments

@andersfr
Copy link
Contributor

Vector types generates special mask-like results for their comparisons.
Below is an example of the problem and a software emulation that LLVM can optimise into the appropriate hardware instruction.

const V = @Vector(16, i8);

fn equal_zig_assumes_result_is_bool(left: V, right: V) V {
    return left == right;
}

fn equal_emulate_hardware(left: V, right: V) V {
    const vl = @ptrCast([*]const i8, &left);
    const vr = @ptrCast([*]const i8, &right);
    var v: V = undefined;
    const arr = @ptrCast([*]i8, &v);

    var i: usize = 0;
    while (i < 16) : (i += 1) {
        if (vl[i] == vr[i]) {
            arr[i] = -1;
        } else {
            arr[i] = 0;
        }
    }

    return v;
}
@andrewrk andrewrk added this to the 0.5.0 milestone Jul 13, 2019
@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. stage1 The process of building from source via WebAssembly and the C backend. labels Jul 13, 2019
@andrewrk
Copy link
Member

This is a not-yet-implemented part of SIMD (#903)

@shawnl
Copy link
Contributor

shawnl commented Jul 26, 2019

Duplicate of #2698, for which there is a proposed patch.

@andrewrk andrewrk removed enhancement Solving this issue will likely involve adding new logic or components to the codebase. stage1 The process of building from source via WebAssembly and the C backend. labels Sep 20, 2019
@andrewrk
Copy link
Member

Yeah dupe of #2698

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants