Skip to content

[AVX-512] Propagating lowest bit to all bits in u64 lane should use sra(sll(x, 63), 63) instead of neg(and(x, 1)) #137575

Open
@Validark

Description

@Validark

Zig Godbolt LLVM Godbolt

export fn foo(vec: @Vector(8, u64)) @Vector(8, u64) {
    return -%((vec << @splat(63)) >> @splat(63));
}

Gives:

.LCPI0_0:
        .quad   1
foo:
        vpandq  zmm0, zmm0, qword ptr [rip + .LCPI0_0]{1to8}
        vpxor   xmm1, xmm1, xmm1
        vpsubq  zmm0, zmm1, zmm0
        ret

Should be:

foo:
        vpsllq  zmm0, zmm0, 63
        vpsraq  zmm0, zmm0, 63
        ret

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions