Skip to content

[X86] Poor code generation for boolean vectors on AVX2 #157131

@jhuber6

Description

@jhuber6

Boolean vectors are often lowered to integral operations. This code generates the expected bitwise operations only when avx512f is available even though it does not require use of mask registers https://clang.godbolt.org/z/vrdbo9YKa.

#include <cstdint>

typedef __attribute__((ext_vector_type(16))) int16_t i16x16;
typedef __attribute__((ext_vector_type(16))) bool i1x16;

int A(i16x16);

void test(i16x16 v, i1x16 a, i1x16 b) {
    i1x16 m = (a & (~b)) != 0;
    if (__builtin_reduce_or(m))
        A(v);
}

This is introduced at the first instruction selection phase, so I am guessing that lowering these is trying to use the mask registers which then get optimized away.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions