https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100672
--- Comment #7 from Zdenek Sojka <zsojka at seznam dot cz> ---
(In reply to Richard Biener from comment #2)
> Maybe sth is wrong with the testcase? clang also results in an abort. Isn't
> right-shift of negative values undefined?
>
Thank you for having a look.
I believe the behavior is fully defined. The vectors are unsigned, and the
conversion to unsigned is done by adding 2**64; this behaves the same:
$ cat testcase.c
typedef unsigned long long __attribute__((__vector_size__ (32))) V;
V
foo (V v)
{
return -(v >> 1);
}
int
main (void)
{
V v = foo ((V) { 0xfffffffffffffffe, 0xfffffffffffffffc,
0xfffffffffffffffa, 0xfffffffffffffff8 });
if (v[0] != 1 || v[1] != 2 || v[2] != 3 || v[3] != 4)
__builtin_abort ();
return 0;
}
Maybe clang behaves the same since the behavior was the same in the moment when
clang was forked.