https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127378
Bug ID: 127378
Summary: widening _BitInt store leaves most significant limb
unwritten on big-endian
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: mmatti.gnu at gmail dot com
Target Milestone: ---
Host: powerpc64-unknown-linux-gnu
Target: powerpc64-*-linux-gnu
gcc.dg/torture/bitint-16.c fails its -O2 execution test on powerpc64-linux
with -m32 since rs6000 _BitInt support went in as r17-4163 (PR117584); that
commit lists it as a known failure. The bug is not rs6000 specific. It is
in the big-endian path of bitint_large_huge::lower_mergeable_stmt in
gimple-lower-bitint.cc, I could not confirm if this affects s390x. The s390
machines on cfarm are down and its target hook sets bitint_ext_full needs
debugging to check the code path.
Reduced testcase:
/* { dg-do run { target bitint } } */
/* { dg-options "-std=c23 -pedantic-errors" } */
#if __BITINT_MAXWIDTH__ >= 768
unsigned _BitInt(512) a;
unsigned _BitInt(768) b = -1;
__attribute__((noipa)) void
foo (unsigned _BitInt(135) *p)
{
a = (_BitInt(135)) (p[0] + p[1]);
}
__attribute__((noipa)) void
bar (unsigned _BitInt(200) *p)
{
b = p[0] + p[1];
}
#endif
int
main ()
{
#if __BITINT_MAXWIDTH__ >= 768
static unsigned _BitInt(135) p[2] = { -1, 0 };
static unsigned _BitInt(200) q[2] = { 1, 2 };
foo (p);
if (a != (unsigned _BitInt(512)) -1)
__builtin_abort ();
bar (q);
if (b != 3)
__builtin_abort ();
#endif
return 0;
}
$ gcc -O2 -std=c23 -m64 bitint-ext-be.c && ./a.out
Aborted