Any thoughts on what f should return in the following testcase, given the
usual GNU behaviour of treating signed >> as arithmetic shift right?

    typedef int vs4 __attribute__((vector_size(16)));
    typedef unsigned int vu4 __attribute__((vector_size(16)));
    int
    f (void)
    {
      vs4 x = { -1, -1, -1, -1 };
      vu4 y = { 0, 0, 0, 0 };
      return ((x + y) >> 1)[0];
    }

The C frontend takes the type of x+y from the first operand, so x+y
is signed and f returns -1.

The C++ frontend applies similar rules to x+y as it would to scalars,
with unsigned T having a higher rank than signed T, so x+y is unsigned
and f returns 0x7fffffff.

FWIW, Clang treats x+y as signed, so f returns -1 for both C and C++.

[Was looking at this in the context of PR96377.]

Thanks,
Richard

Reply via email to