For this code:
...
__int128 min_one = -1;
...
we currently generate:
...
.visible .global .align 8 .u64 min_one[2] = { -1, 0 };
...
Fix this in nvptx_assemble_value, such that we have instead:
...
.visible .global .align 8 .u64 min_one[2] = { -1, -1 };
...
gcc/ChangeLog:
* config/nvptx/nvptx.c (nvptx_assemble_value): Handle negative
__int128.
gcc/testsuite/ChangeLog:
* gcc.target/nvptx/int128.c: New test.
static void
nvptx_assemble_value (unsigned HOST_WIDE_INT val, unsigned size)
{
+ bool negative_p
+ = val & (HOST_WIDE_INT_1U << (HOST_BITS_PER_WIDE_INT - 1));
+
val &= ((unsigned HOST_WIDE_INT)2 << (size * BITS_PER_UNIT - 1)) - 1;
for (unsigned part = 0; size; size -= part)
{
if (part * BITS_PER_UNIT == HOST_BITS_PER_WIDE_INT)
/* Avoid undefined behaviour. */
- val = 0;
+ val = negative_p ? -1 : 0;
else
val >>= (part * BITS_PER_UNIT);
part = init_frag.size - init_frag.offset;
--- /dev/null
+/* { dg-do run } */
+/* { dg-additional-options "-Wno-pedantic" } */
+
+__int128 one = 1;
+__int128 min_one = -1;
+__int128 zero = 0;
+
+int
+main (void)
+{
+ if (zero - one != min_one)
+ __builtin_abort ();
+
+ return 0;
+}