[Bug target/64358] New: Wrong code for __int128 operations in powerpc64le
roger.ferrer at bsc dot es
gcc-bugzilla@gcc.gnu.org
Fri Dec 19 11:35:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64358
Bug ID: 64358
Summary: Wrong code for __int128 operations in powerpc64le
Product: gcc
Version: 4.9.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: roger.ferrer at bsc dot es
Hi,
I'm observing a weird behaviour in PowerPC64 Little Endian that does not seem
to occur on other architectures supporting __int128. The following code, when
compiled with -O1 generates wrong output in gcc 4.9.1.
-- test.c
#include <stdio.h>
typedef unsigned __int128 uint128_t;
#define PRINT(value) \
{ union u { uint128_t i; unsigned long long l[2]; } _t = { .i = value }; \
fprintf(stderr, "%s => <%016llx, %016llx>\n", #value, _t.l[1],
_t.l[0]); }
__attribute__((noinline))
uint128_t get_int(uint128_t value, unsigned int num_bytes)
{
uint128_t mask = ~(uint128_t)0;
mask <<= (uint128_t)(8 * num_bytes); /* assuming 1 byte = 8 bits */
mask = ~mask;
value &= mask;
return value;
}
int main(int argc, char* argv[])
{
uint128_t x = 0;
x = get_int(10, /* num_bytes */ 1);
PRINT(x);
return 0;
}
-- end of test.c
The problem is still present in a recent version from the svn:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/home/Computational/rferrer/gcc/install/bin/gcc
COLLECT_LTO_WRAPPER=/home/Computational/rferrer/gcc/install/libexec/gcc/powerpc64le-unknown-linux-gnu/5.0.0/lto-wrapper
Target: powerpc64le-unknown-linux-gnu
Configured with: ../gcc-src/configure
--prefix=/home/Computational/rferrer/gcc/install
--enable-languages=c,c++,fortran
--with-gmp=/home/Computational/rferrer/gcc/install
--with-mpfr=/home/Computational/rferrer/gcc/install
--with-mpc=/home/Computational/rferrer/gcc/install --enable-multiarch
--disable-multilib
Thread model: posix
gcc version 5.0.0 20141218 (experimental) (GCC)
$ make
gcc -O0 -o test.O0 test.c
./test.O0
x => <0000000000000000, 000000000000000a>
gcc -O1 -o test.O1 test.c
./test.O1
x => <ffffffffffffffff, ffffffffffffff00>
Kind regards,
More information about the Gcc-bugs
mailing list