[Bug target/58790] New: [missed optimization] reduction of masks of builtin vectors not transformed to ptest or movemask instructions

kretz at kde dot org gcc-bugzilla@gcc.gnu.org
Fri Oct 18 16:05:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58790

            Bug ID: 58790
           Summary: [missed optimization] reduction of masks of builtin
                    vectors not transformed to ptest or movemask
                    instructions
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kretz at kde dot org

Testcase:
typedef int int32_4v __attribute__((__vector_size__(16)));
typedef long long int64_2v __attribute__((__vector_size__(16)));

bool all_equal1(int32_4v a, int32_4v b)
{
    const auto k = a == b;
    return k[0] && k[1] && k[2] && k[3];
}

bool all_equal2(int32_4v a, int32_4v b)
{
    const auto k = a == b;
    return __builtin_ia32_ptestc128((int64_2v)k, __extension__(int64_2v){-1,
-1});
}

bool none_equal1(int32_4v a, int32_4v b)
{
    const auto k = a == b;
    return !k[0] && !k[1] && !k[2] && !k[3];
}

bool none_equal2(int32_4v a, int32_4v b)
{
    const auto k = a == b;
    return __builtin_ia32_ptestz128((int64_2v)k, (int64_2v)k);
}

bool some_equal1(int32_4v a, int32_4v b)
{
    return !all_equal1(a, b) && !none_equal1(a, b);
}

bool some_equal2(int32_4v a, int32_4v b)
{
    return !all_equal2(a, b) && !none_equal2(a, b);
}

bool some_equal3(int32_4v a, int32_4v b)
{
    const auto k = a == b;
    return __builtin_ia32_ptestnzc128((int64_2v)k, __extension__(int64_2v){-1,
-1});
}

Compile with -O3 -msse4 -std=c++11.

The all_equal2, none_equal2, and some_equal3 functions use explicit calls to
the ptest builtins to lead to the expected optimizations. All the other
functions should get optimized accordingly.



More information about the Gcc-bugs mailing list