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

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
As testcase I've been so far using just
[[gnu::noipa]] unsigned int
foo (unsigned int x, unsigned int y)
{
  return __builtin_clmulg (x, y);
}

[[gnu::noipa]] unsigned long long
qux (unsigned long long x, unsigned long long y, unsigned long long *z)
{
  return __builtin_clmulg (x, y, z);
}

[[gnu::noipa]] unsigned long long
garply (unsigned long long x, unsigned long long y)
{
  return __builtin_clmulg (x, y);
}

#ifdef __SIZEOF_INT128__
[[gnu::noipa]] unsigned __int128
xyzzy (unsigned __int128 x, unsigned __int128 y)
{
  return __builtin_clmulg (x, y);
}
#endif

unsigned long long
bar ()
{
  unsigned int hi;
  unsigned int lo = __builtin_clmulg (0x12345678U, 0x23456789U, &hi);
  return lo | (((unsigned long long) hi) << 32);
}

unsigned long long
baz ()
{
  return __builtin_clmulg (0x12345678ULL, 0x23456789ULL);
}

[[gnu::noipa]] unsigned _BitInt(1024)
fred (unsigned _BitInt(1024) x, unsigned _BitInt(1024) y)
{
  return __builtin_clmulg (x, y);
}

[[gnu::noipa]] unsigned _BitInt(1024)
corge (unsigned _BitInt(1024) x, unsigned _BitInt(1024) y, unsigned
_BitInt(1024) *z)
{
  return __builtin_clmulg (x, y, z);
}

int
main ()
{
  if (foo (0x123U, 0x234U) != __builtin_clmulg (0x123U, 0x234U))
    __builtin_abort ();
  if (foo (0xb7acb12aU, 0xd9485812U) != __builtin_clmulg (0xb7acb12aU,
0xd9485812U))
    __builtin_abort ();
  if (foo (0x5017894fU, 0x114e477eU) != __builtin_clmulg (0x5017894fU,
0x114e477eU))
    __builtin_abort ();
  if (garply (0x1111111111111111ULL, 0x1111111111111111ULL)
      != __builtin_clmulg (0x1111111111111111ULL, 0x1111111111111111ULL))
    __builtin_abort ();
  if (garply (~0ULL, ~0ULL) != __builtin_clmulg (~0ULL, ~0ULL))
    __builtin_abort ();
  unsigned long long hi1, hi2;
  if (qux (0x1111111111111111ULL, 0x1111111111111111ULL, &hi1)
      != __builtin_clmulg (0x1111111111111111ULL, 0x1111111111111111ULL, &hi2)
      || hi1 != hi2)
    __builtin_abort ();
  if (qux (~0ULL, ~0ULL, &hi1) != __builtin_clmulg (~0ULL, ~0ULL, &hi2)
      || hi1 != hi2)
    __builtin_abort ();
#if __SIZEOF_INT128__
  if (xyzzy (0x1111111111111111ULL, 0x1111111111111111ULL)
      != __builtin_clmulg ((unsigned __int128) 0x1111111111111111ULL,
                           (unsigned __int128) 0x1111111111111111ULL))
    __builtin_abort ();
  if (xyzzy (~(unsigned __int128) 0, ~(unsigned __int128) 0)
      != __builtin_clmulg (~(unsigned __int128) 0, ~(unsigned __int128) 0))
    __builtin_abort ();
#endif
}

Will need to start writing testcase coverages and docs.

Reply via email to