https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100672

--- Comment #10 from Zdenek Sojka <zsojka at seznam dot cz> ---
(In reply to Zdenek Sojka from comment #9)
> (In reply to Richard Biener from comment #8)
> > (In reply to Zdenek Sojka from comment #7)
> > > (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);
> > 
> > but this is a logical right shift, thus gives 0x7ff...e, ...
> > and negating that doesn't yield 1.
> > 
> 
> Shame on me. You are very right.

I did the mistake while reducing the testcase.
The original testcase had positive arguments:

$ 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) { 2, 4, 6, 8 });
  if (v[0] != 0xffffffffffffffff || v[1] != 0xfffffffffffffffe ||
      v[2] != 0xfffffffffffffffd || v[3] != 0xfffffffffffffffc)
    __builtin_abort ();
  return 0;
}


I wanted to prevent the long 0xfffff... constants, but broke the testcase in he
process. Thank you for correcting me.

Reply via email to