public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/96399] New: Arithmetic shift with vector extension becomes logical right shift on s390x
@ 2020-07-31  8:58 yohei at jp dot ibm.com
  2020-07-31  9:08 ` [Bug c/96399] " yohei at jp dot ibm.com
  2020-07-31  9:16 ` jakub at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: yohei at jp dot ibm.com @ 2020-07-31  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96399
           Summary: Arithmetic shift with vector extension becomes logical
                    right shift on s390x
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yohei at jp dot ibm.com
  Target Milestone: ---

When I applied arithmetic shift (>>) to a 16-element signed char vector
variable, I observed behavior of logical right shift on s390x.

-----
#include <stdio.h>

typedef char vec16char __attribute__ ((vector_size (16)));

void test(vec16char *p, vec16char *q)
{
    *q = *p >> 7;
}

int main(int argc, char *argv[])
{
    vec16char in = {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
                    0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80};
    vec16char out;

    test(&in, &out);

    printf("out[0] = %d\n", out[0]);
}
-----

I compiled the above code with gcc -Wall -march=z14 -O3 -o vectest vectest.c

Then, I got the following output on s390x:

out[0] = 1

I expected the following output:

out[0] = -1

At least on x86_64, I got the expected output.

On s390x, vesrlb is generated, but I think vesrab is appropriate.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/96399] Arithmetic shift with vector extension becomes logical right shift on s390x
  2020-07-31  8:58 [Bug c/96399] New: Arithmetic shift with vector extension becomes logical right shift on s390x yohei at jp dot ibm.com
@ 2020-07-31  9:08 ` yohei at jp dot ibm.com
  2020-07-31  9:16 ` jakub at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: yohei at jp dot ibm.com @ 2020-07-31  9:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Yohei Ueda <yohei at jp dot ibm.com> ---
Output of gcc -v:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/s390x-linux-gnu/10.2.0/lto-wrapper
Target: s390x-linux-gnu
Configured with: /usr/src/gcc/configure --build=s390x-linux-gnu
--disable-multilib --enable-languages=c,c++,fortran,go
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (GCC)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/96399] Arithmetic shift with vector extension becomes logical right shift on s390x
  2020-07-31  8:58 [Bug c/96399] New: Arithmetic shift with vector extension becomes logical right shift on s390x yohei at jp dot ibm.com
  2020-07-31  9:08 ` [Bug c/96399] " yohei at jp dot ibm.com
@ 2020-07-31  9:16 ` jakub at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-07-31  9:16 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
s390x defaults to -funsigned-char, while x86_64 defaults to -fsigned-char, so
what you get is exactly what should happen.  If you want portable code, you
should use signed char or unsigned char and use char only if you don't care if
it is signed or unsigned.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-31  9:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31  8:58 [Bug c/96399] New: Arithmetic shift with vector extension becomes logical right shift on s390x yohei at jp dot ibm.com
2020-07-31  9:08 ` [Bug c/96399] " yohei at jp dot ibm.com
2020-07-31  9:16 ` jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).