[5/5] testsuite part 2 for _BitInt support [PR102989]

Message ID ZMKmdrWbE6owq+KJ@tucnak
State Unresolved
Headers
Series GCC _BitInt support [PR102989] |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek July 27, 2023, 5:16 p.m. UTC
  Hi!

This is second part of the testcase additions in order to fit into
mailing lists limits.  Most of these tests are for the floating
point conversions, __builtin_*_overflow and -fsanitize=undefined.

2023-07-27  Jakub Jelinek  <jakub@redhat.com>

	PR c/102989
gcc/testsuite/
	* gcc.dg/torture/bitint-20.c: New test.
	* gcc.dg/torture/bitint-21.c: New test.
	* gcc.dg/torture/bitint-22.c: New test.
	* gcc.dg/torture/bitint-23.c: New test.
	* gcc.dg/torture/bitint-24.c: New test.
	* gcc.dg/torture/bitint-25.c: New test.
	* gcc.dg/torture/bitint-26.c: New test.
	* gcc.dg/torture/bitint-27.c: New test.
	* gcc.dg/torture/bitint-28.c: New test.
	* gcc.dg/torture/bitint-29.c: New test.
	* gcc.dg/torture/bitint-30.c: New test.
	* gcc.dg/torture/bitint-31.c: New test.
	* gcc.dg/torture/bitint-32.c: New test.
	* gcc.dg/torture/bitint-33.c: New test.
	* gcc.dg/torture/bitint-34.c: New test.
	* gcc.dg/torture/bitint-35.c: New test.
	* gcc.dg/torture/bitint-36.c: New test.
	* gcc.dg/torture/bitint-37.c: New test.
	* gcc.dg/torture/bitint-38.c: New test.
	* gcc.dg/torture/bitint-39.c: New test.
	* gcc.dg/torture/bitint-40.c: New test.
	* gcc.dg/torture/bitint-41.c: New test.
	* gcc.dg/ubsan/bitint-1.c: New test.
	* gcc.dg/ubsan/bitint-2.c: New test.
	* gcc.dg/ubsan/bitint-3.c: New test.


	Jakub
  

Comments

Joseph Myers July 27, 2023, 7:06 p.m. UTC | #1
I think there should be tests for _Atomic _BitInt types.  Hopefully atomic 
compound assignment just works via the logic for compare-and-exchange 
loops, but does e.g. atomic_fetch_add work with _Atomic _BitInt types?
  
Jakub Jelinek July 28, 2023, 11:43 a.m. UTC | #2
On Thu, Jul 27, 2023 at 07:06:03PM +0000, Joseph Myers wrote:
> I think there should be tests for _Atomic _BitInt types.  Hopefully atomic 
> compound assignment just works via the logic for compare-and-exchange 
> loops, but does e.g. atomic_fetch_add work with _Atomic _BitInt types?

So, there are 2 issues.

One is something I haven't seen being handled for C at all so far, but
handled for C++ - padding bits.

Already e.g. x86 long double has some padding bits - 16 bits on ia32,
48 bits on x86_64, when one does
  _Atomic long double l;
...
  l += 2.0;
it will sometimes work and sometimes hang forever.
Similarly atomic_compare_exchange with structs which contain padding
(unions with padding bits are lost case, there is nothing that can be
reliably done for that, because we don't know at runtime what is the active
union member if any).  And _BitInt if it doesn't use all bits in
all containing limbs has padding as well (and psABI doesn't say it is sign
or zero extended).

The C++ way of dealing with this is using __builtin_clear_padding,
done on atomic stores/updates of the atomic memory (padding is cleared
if any on the value to be stored, or on the expected and desired values).

I don't know enough about the C atomic requirements whether that is feasible
for it as well, or whether it is possible to make the padding bits partially
or fully set somehow non-atomically without invoking UB and then make it
never match.

If one ignores this or deals with it, then

_Atomic _BitInt(15) a;
_Atomic(_BitInt(15)) b;
_Atomic _BitInt(115) c;
_Atomic _BitInt(192) d;
_Atomic _BitInt(575) e;
_BitInt(575) f;

int
main ()
{
  a += 1wb;
  b -= 2wb;
  c += 3wb;
  d += 4wb;
  e -= 5wb;
//  f = __atomic_fetch_add (&e, 54342985743985743985743895743834298574985734895743895734895wb, __ATOMIC_SEQ_CST);
}

compiles fine with the patch set.

And another issue is that while __atomic_load, __atomic_store,
__atomic_exchange and __atomic_compare_exchange work on arbitrary _BitInt
sizes, others like __atomic_fetch_add only support _BitInt or other integral
types which have size of 1, 2, 4, 8 or 16 bytes, others emit an error
in c-family/c-common.cc (sync_resolve_size).  So, either
resolve_overloaded_builtin should for the case when pointer is pointer to
_BitInt which doesn't have 1, 2, 4, 8 or 16 bytes size lower those into
a loop using __atomic_compare_exchange (or perhaps also if there is
padding), or <stdatomic.h> should do that.

Thoughts on that?

	Jakub
  
Martin Uecker July 28, 2023, 2:03 p.m. UTC | #3
> On Thu, Jul 27, 2023 at 07:06:03PM +0000, Joseph Myers wrote:
> > I think there should be tests for _Atomic _BitInt types.  Hopefully atomic 
> > compound assignment just works via the logic for compare-and-exchange 
> > loops, but does e.g. atomic_fetch_add work with _Atomic _BitInt types?
> 
> So, there are 2 issues.
> 
> One is something I haven't seen being handled for C at all so far, but
> handled for C++ - padding bits.
> 
> Already e.g. x86 long double has some padding bits - 16 bits on ia32,
> 48 bits on x86_64, when one does
>   _Atomic long double l;
> ...
>   l += 2.0;
> it will sometimes work and sometimes hang forever.
> Similarly atomic_compare_exchange with structs which contain padding
> (unions with padding bits are lost case, there is nothing that can be
> reliably done for that, because we don't know at runtime what is the active
> union member if any).  And _BitInt if it doesn't use all bits in
> all containing limbs has padding as well (and psABI doesn't say it is sign
> or zero extended).

What is the problem here?  In C, atomic_compare_exchange is defined in terms
of the memory content which includes padding.  So it may fail spuriously
due to padding differences (but it may fail anyway for arbitrary reasons
even without padding differences), but then should work in the second 
iterations.

Martin
  
Martin Uecker July 28, 2023, 2:06 p.m. UTC | #4
Am Freitag, dem 28.07.2023 um 16:03 +0200 schrieb Martin Uecker:
> 
> > On Thu, Jul 27, 2023 at 07:06:03PM +0000, Joseph Myers wrote:
> > > I think there should be tests for _Atomic _BitInt types.  Hopefully atomic 
> > > compound assignment just works via the logic for compare-and-exchange 
> > > loops, but does e.g. atomic_fetch_add work with _Atomic _BitInt types?
> > 
> > So, there are 2 issues.
> > 
> > One is something I haven't seen being handled for C at all so far, but
> > handled for C++ - padding bits.
> > 
> > Already e.g. x86 long double has some padding bits - 16 bits on ia32,
> > 48 bits on x86_64, when one does
> >   _Atomic long double l;
> > ...
> >   l += 2.0;
> > it will sometimes work and sometimes hang forever.
> > Similarly atomic_compare_exchange with structs which contain padding
> > (unions with padding bits are lost case, there is nothing that can be
> > reliably done for that, because we don't know at runtime what is the active
> > union member if any).  And _BitInt if it doesn't use all bits in
> > all containing limbs has padding as well (and psABI doesn't say it is sign
> > or zero extended).
> 
> What is the problem here?  In C, atomic_compare_exchange is defined in terms
> of the memory content which includes padding.  So it may fail spuriously
> due to padding differences (but it may fail anyway for arbitrary reasons
> even without padding differences), but then should work in the second 
> iterations.

(only the weak version can fail spuriously, but the strong one can still
fail if there are differences in the padding)
  
Jakub Jelinek July 28, 2023, 2:26 p.m. UTC | #5
On Fri, Jul 28, 2023 at 04:03:39PM +0200, Martin Uecker wrote:
> > On Thu, Jul 27, 2023 at 07:06:03PM +0000, Joseph Myers wrote:
> > > I think there should be tests for _Atomic _BitInt types.  Hopefully atomic 
> > > compound assignment just works via the logic for compare-and-exchange 
> > > loops, but does e.g. atomic_fetch_add work with _Atomic _BitInt types?
> > 
> > So, there are 2 issues.
> > 
> > One is something I haven't seen being handled for C at all so far, but
> > handled for C++ - padding bits.
> > 
> > Already e.g. x86 long double has some padding bits - 16 bits on ia32,
> > 48 bits on x86_64, when one does
> >   _Atomic long double l;
> > ...
> >   l += 2.0;
> > it will sometimes work and sometimes hang forever.
> > Similarly atomic_compare_exchange with structs which contain padding
> > (unions with padding bits are lost case, there is nothing that can be
> > reliably done for that, because we don't know at runtime what is the active
> > union member if any).  And _BitInt if it doesn't use all bits in
> > all containing limbs has padding as well (and psABI doesn't say it is sign
> > or zero extended).
> 
> What is the problem here?  In C, atomic_compare_exchange is defined in terms
> of the memory content which includes padding.  So it may fail spuriously
> due to padding differences (but it may fail anyway for arbitrary reasons
> even without padding differences), but then should work in the second 
> iterations.

See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0528r3.html
for background.  The thing is that user doesn't have much control over those
padding bits, so whether _Atomic operations on long double (when it is 80
bit and stores from hw actually store 10 bytes rather than 12 or 16), or
_BitInt(37) or _BitInt(195) or struct S { char a; int b; }; then depend
purely on luck.  If the expected value is based on atomic_load on the
atomic_compare_exchange location or whatever atomic_compare_exchange gave
back, if in the loop one e.g. adds something to it, then again it might get
different padding bits from what is originally in memory, so it isn't true
that it will always succeed at least in the second loop iteration.

	Jakub
  
Martin Uecker July 28, 2023, 2:53 p.m. UTC | #6
Am Freitag, dem 28.07.2023 um 16:26 +0200 schrieb Jakub Jelinek:
> On Fri, Jul 28, 2023 at 04:03:39PM +0200, Martin Uecker wrote:
> > > On Thu, Jul 27, 2023 at 07:06:03PM +0000, Joseph Myers wrote:
> > > > I think there should be tests for _Atomic _BitInt types.  Hopefully atomic 
> > > > compound assignment just works via the logic for compare-and-exchange 
> > > > loops, but does e.g. atomic_fetch_add work with _Atomic _BitInt types?
> > > 
> > > So, there are 2 issues.
> > > 
> > > One is something I haven't seen being handled for C at all so far, but
> > > handled for C++ - padding bits.
> > > 
> > > Already e.g. x86 long double has some padding bits - 16 bits on ia32,
> > > 48 bits on x86_64, when one does
> > >   _Atomic long double l;
> > > ...
> > >   l += 2.0;
> > > it will sometimes work and sometimes hang forever.
> > > Similarly atomic_compare_exchange with structs which contain padding
> > > (unions with padding bits are lost case, there is nothing that can be
> > > reliably done for that, because we don't know at runtime what is the active
> > > union member if any).  And _BitInt if it doesn't use all bits in
> > > all containing limbs has padding as well (and psABI doesn't say it is sign
> > > or zero extended).
> > 
> > What is the problem here?  In C, atomic_compare_exchange is defined in terms
> > of the memory content which includes padding.  So it may fail spuriously
> > due to padding differences (but it may fail anyway for arbitrary reasons
> > even without padding differences), but then should work in the second 
> > iterations.
> 
> See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0528r3.html
> for background.  

Thanks. I have seen this at that time, but it seems to refer to 
C++ specific problems. At least at that time, I concluded (maybe
incorrectly) that this is not a serious problem for how things 
work in C.


> The thing is that user doesn't have much control over those
> padding bits, so whether _Atomic operations on long double (when it is 80
> bit and stores from hw actually store 10 bytes rather than 12 or 16), or
> _BitInt(37) or _BitInt(195) or struct S { char a; int b; }; then depend
> purely on luck.  If the expected value is based on atomic_load on the
> atomic_compare_exchange location or whatever atomic_compare_exchange gave
> back, if in the loop one e.g. adds something to it, then again it might get
> different padding bits from what is originally in memory, so it isn't true
> that it will always succeed at least in the second loop iteration.

Sorry, somehow I must be missing something here.

If you add something you would create a new value and this may (in
an object) have random new padding.  But the "expected" value should
be updated by a failed atomic_compare_exchange cycle and then have
same padding as the value stored in the atomic. So the next cycle
should succeed.  The user would not change the representation of
the "expected" value but create a new value for another object
by adding something.


Martin
  
Jakub Jelinek July 28, 2023, 3:10 p.m. UTC | #7
On Fri, Jul 28, 2023 at 04:53:30PM +0200, Martin Uecker wrote:
> > The thing is that user doesn't have much control over those
> > padding bits, so whether _Atomic operations on long double (when it is 80
> > bit and stores from hw actually store 10 bytes rather than 12 or 16), or
> > _BitInt(37) or _BitInt(195) or struct S { char a; int b; }; then depend
> > purely on luck.  If the expected value is based on atomic_load on the
> > atomic_compare_exchange location or whatever atomic_compare_exchange gave
> > back, if in the loop one e.g. adds something to it, then again it might get
> > different padding bits from what is originally in memory, so it isn't true
> > that it will always succeed at least in the second loop iteration.
> 
> Sorry, somehow I must be missing something here.
> 
> If you add something you would create a new value and this may (in
> an object) have random new padding.  But the "expected" value should
> be updated by a failed atomic_compare_exchange cycle and then have
> same padding as the value stored in the atomic. So the next cycle
> should succeed.  The user would not change the representation of
> the "expected" value but create a new value for another object
> by adding something.

You're right that it would pass the expected value not something after an
operation on it usually.  But still, expected type will be something like
_BitInt(37) or _BitInt(195) and so neither the atomic_load nor what
atomic_compare_exchange copies back on failure is guaranteed to have the
padding bits preserved.
It is true that if it is larger than 16 bytes the libatomic
atomic_compare_exchange will memcpy the value back which copies the padding
bits, but is there a guarantee that the user code doesn't actually copy that
value further into some other variable?  Anyway, for smaller or equal
to 16 (or 8) bytes if atomic_compare_exchange is emitted inline I don't see
what would preserve the bits.

	Jakub
  
Martin Uecker July 28, 2023, 4:01 p.m. UTC | #8
Am Freitag, dem 28.07.2023 um 17:10 +0200 schrieb Jakub Jelinek:
> On Fri, Jul 28, 2023 at 04:53:30PM +0200, Martin Uecker wrote:
> > > The thing is that user doesn't have much control over those
> > > padding bits, so whether _Atomic operations on long double (when it is 80
> > > bit and stores from hw actually store 10 bytes rather than 12 or 16), or
> > > _BitInt(37) or _BitInt(195) or struct S { char a; int b; }; then depend
> > > purely on luck.  If the expected value is based on atomic_load on the
> > > atomic_compare_exchange location or whatever atomic_compare_exchange gave
> > > back, if in the loop one e.g. adds something to it, then again it might get
> > > different padding bits from what is originally in memory, so it isn't true
> > > that it will always succeed at least in the second loop iteration.
> > 
> > Sorry, somehow I must be missing something here.
> > 
> > If you add something you would create a new value and this may (in
> > an object) have random new padding.  But the "expected" value should
> > be updated by a failed atomic_compare_exchange cycle and then have
> > same padding as the value stored in the atomic. So the next cycle
> > should succeed.  The user would not change the representation of
> > the "expected" value but create a new value for another object
> > by adding something.
> 
> You're right that it would pass the expected value not something after an
> operation on it usually.  But still, expected type will be something like
> _BitInt(37) or _BitInt(195) and so neither the atomic_load nor what
> atomic_compare_exchange copies back on failure is guaranteed to have the
> padding bits preserved.

For atomic_load in C a value is returned. A value does not care about
padding and when stored into a new object can produce new and different
padding.  

But for atomic_compare_exchange the memory content is copied into 
an object passed by pointer, so here the C standard requires to
that the padding is preserved. It explicitely states that the effect
is like:

if (memcmp(object, expected, sizeof(*object)) == 0)
  memcpy(object, &desired, sizeof(*object));
else
  memcpy(expected, object, sizeof(*object));


> It is true that if it is larger than 16 bytes the libatomic
> atomic_compare_exchange will memcpy the value back which copies the padding
> bits, but is there a guarantee that the user code doesn't actually copy that
> value further into some other variable?  

I do not think it would be surprising for C user when
the next atomic_compare_exchange fails in this case.

> Anyway, for smaller or equal
> to 16 (or 8) bytes if atomic_compare_exchange is emitted inline I don't see
> what would preserve the bits.

This then seems to be incorrect for C.

Martin
  
Joseph Myers July 28, 2023, 6:32 p.m. UTC | #9
On Fri, 28 Jul 2023, Jakub Jelinek via Gcc-patches wrote:

> The C++ way of dealing with this is using __builtin_clear_padding,
> done on atomic stores/updates of the atomic memory (padding is cleared
> if any on the value to be stored, or on the expected and desired values).
> 
> I don't know enough about the C atomic requirements whether that is feasible
> for it as well, or whether it is possible to make the padding bits partially
> or fully set somehow non-atomically without invoking UB and then make it
> never match.

If padding bits not being reliably preserved causes problems for the 
compare-exchange loops in C in practice, then it would seem reasonable to 
use __builtin_clear_padding internally as part of implementing those cases 
of atomic compound assignment.

> And another issue is that while __atomic_load, __atomic_store,
> __atomic_exchange and __atomic_compare_exchange work on arbitrary _BitInt
> sizes, others like __atomic_fetch_add only support _BitInt or other integral
> types which have size of 1, 2, 4, 8 or 16 bytes, others emit an error
> in c-family/c-common.cc (sync_resolve_size).  So, either
> resolve_overloaded_builtin should for the case when pointer is pointer to
> _BitInt which doesn't have 1, 2, 4, 8 or 16 bytes size lower those into
> a loop using __atomic_compare_exchange (or perhaps also if there is
> padding), or <stdatomic.h> should do that.

The <stdatomic.h> interfaces definitely need to work with _BitInt.  My 
guess is that doing this with the built-in expansion would be more robust 
than putting more complicated definitions in the header that choose which 
built-in functions to use depending on properties of the type (and keeping 
the built-in functions limited to certain widths), but I don't know.

Note also that those <stdatomic.h> operations have no undefined behavior 
on signed integer overflow.

If any ABIs require sign / zero extension of _BitInt values in memory, 
care would also be needed in the case of (size of 1, 2, 4, 8 or 16 bytes, 
but also has high bits required to be sign / zero extended) to ensure that 
the operations are implemented so as to leave the high bits with the 
expected values in case of overflow, which wouldn't result from simply 
using the underlying operation for a type with the full precision of its 
memory size.
  
Michael Matz July 31, 2023, 2:33 p.m. UTC | #10
Hello,

On Fri, 28 Jul 2023, Martin Uecker wrote:

> > > Sorry, somehow I must be missing something here.
> > > 
> > > If you add something you would create a new value and this may (in
> > > an object) have random new padding.  But the "expected" value should
> > > be updated by a failed atomic_compare_exchange cycle and then have
> > > same padding as the value stored in the atomic. So the next cycle
> > > should succeed.  The user would not change the representation of
> > > the "expected" value but create a new value for another object
> > > by adding something.
> > 
> > You're right that it would pass the expected value not something after an
> > operation on it usually.  But still, expected type will be something like
> > _BitInt(37) or _BitInt(195) and so neither the atomic_load nor what
> > atomic_compare_exchange copies back on failure is guaranteed to have the
> > padding bits preserved.
> 
> For atomic_load in C a value is returned. A value does not care about
> padding and when stored into a new object can produce new and different
> padding.  
> 
> But for atomic_compare_exchange the memory content is copied into 
> an object passed by pointer, so here the C standard requires to
> that the padding is preserved. It explicitely states that the effect
> is like:
> 
> if (memcmp(object, expected, sizeof(*object)) == 0)
>   memcpy(object, &desired, sizeof(*object));
> else
>   memcpy(expected, object, sizeof(*object));
> 
> > It is true that if it is larger than 16 bytes the libatomic 
> > atomic_compare_exchange will memcpy the value back which copies the 
> > padding bits, but is there a guarantee that the user code doesn't 
> > actually copy that value further into some other variable?  
> 
> I do not think it would be surprising for C user when
> the next atomic_compare_exchange fails in this case.

But that is a problem (the same one the cited C++ paper tries to resolve, 
IIUC).  Say you have a loop like so:

_Atomic T obj;
...
T expected1, expected2, newval;
newval = ...;
expected1 = ...;
do {
  expected2 = expected1;
  if (atomic_compare_exchange_weak(&obj, &expected2, newval);
    break;
  expected1 = expected2;
} while (1);

As written this looks of course stupid, and you may say "don't do that", 
but internally the copies might result from temporaries (compiler 
generated or wrapper function arguments, or suchlike).  Now, while 
expected2 will contain the copied padding bits after the cmpxchg the 
copies to and from expected1 will possibly destroy them.  Either way I 
don't see why the above loop should be out-of-spec, so I can write it and 
expect it to proceed eventually (certainly when the _strong variant is 
used).  Any argument that would declare the above loop out-of-spec I would 
consider a defect in the spec.

It's never a good idea to introduce reliance on padding bits.  Exactly 
because you can trivially destroy them with simple value copies.

> > Anyway, for smaller or equal to 16 (or 8) bytes if 
> > atomic_compare_exchange is emitted inline I don't see what would 
> > preserve the bits.
> 
> This then seems to be incorrect for C.

Or the spec is.


Ciao,
Michael.
  
Martin Uecker July 31, 2023, 3:37 p.m. UTC | #11
Am Montag, dem 31.07.2023 um 14:33 +0000 schrieb Michael Matz:
> Hello,
> 
> On Fri, 28 Jul 2023, Martin Uecker wrote:
> 
> > > > Sorry, somehow I must be missing something here.
> > > > 
> > > > If you add something you would create a new value and this may (in
> > > > an object) have random new padding.  But the "expected" value should
> > > > be updated by a failed atomic_compare_exchange cycle and then have
> > > > same padding as the value stored in the atomic. So the next cycle
> > > > should succeed.  The user would not change the representation of
> > > > the "expected" value but create a new value for another object
> > > > by adding something.
> > > 
> > > You're right that it would pass the expected value not something after an
> > > operation on it usually.  But still, expected type will be something like
> > > _BitInt(37) or _BitInt(195) and so neither the atomic_load nor what
> > > atomic_compare_exchange copies back on failure is guaranteed to have the
> > > padding bits preserved.
> > 
> > For atomic_load in C a value is returned. A value does not care about
> > padding and when stored into a new object can produce new and different
> > padding.  
> > 
> > But for atomic_compare_exchange the memory content is copied into 
> > an object passed by pointer, so here the C standard requires to
> > that the padding is preserved. It explicitely states that the effect
> > is like:
> > 
> > if (memcmp(object, expected, sizeof(*object)) == 0)
> >   memcpy(object, &desired, sizeof(*object));
> > else
> >   memcpy(expected, object, sizeof(*object));
> > 
> > > It is true that if it is larger than 16 bytes the libatomic 
> > > atomic_compare_exchange will memcpy the value back which copies the 
> > > padding bits, but is there a guarantee that the user code doesn't 
> > > actually copy that value further into some other variable?  
> > 
> > I do not think it would be surprising for C user when
> > the next atomic_compare_exchange fails in this case.
> 
> But that is a problem (the same one the cited C++ paper tries to resolve, 
> IIUC). 

I do not quite understand the paper. I can't see
how the example 3 in

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0528r0.html

could loop indefinitely with the memcpy / memcmp semantics,
but somehow the authors seem to claim this. 


>  Say you have a loop like so:
> 
> _Atomic T obj;
> ...
> T expected1, expected2, newval;
> newval = ...;
> expected1 = ...;
> do {
>   expected2 = expected1;
>   if (atomic_compare_exchange_weak(&obj, &expected2, newval);
>     break;
>   expected1 = expected2;
> } while (1);
> 
> As written this looks of course stupid, and you may say "don't do that", 
> but internally the copies might result from temporaries (compiler 
> generated or wrapper function arguments, or suchlike). 
>  Now, while 
> expected2 will contain the copied padding bits after the cmpxchg the 
> copies to and from expected1 will possibly destroy them.  Either way I 
> don't see why the above loop should be out-of-spec, so I can write it and 
> expect it to proceed eventually (certainly when the _strong variant is 
> used).  Any argument that would declare the above loop out-of-spec I would 
> consider a defect in the spec.

It is "out-of-spec" for C in the sense that it can not be
expected work with the semantics as specified in the C standard.

But I agree with you that it would be better if it just worked.

A compiler could, for example, always clear the padding when
initializing or storing atomic values.  It might also clear
the padding of the initial "expected", when it is
initialized or stored to.

But it should not clear / ignore the padding when copying 
to "expected" using atomic_compare_exhange or when comparing
to the memory content. See below why I think this would not
be helpful.

> 
> It's never a good idea to introduce reliance on padding bits.  Exactly 
> because you can trivially destroy them with simple value copies.
> 
> > > Anyway, for smaller or equal to 16 (or 8) bytes if 
> > > atomic_compare_exchange is emitted inline I don't see what would 
> > > preserve the bits.
> > 
> > This then seems to be incorrect for C.
> 
> Or the spec is.

In practice, what the semantics specified using memcpy/memcmp
allow one to do is to also apply atomic operations on non-atomic 
types.  This is not guaranteed to work by the C standard, but
in practice  people often have to do this.  For example, nobody
is going to copy a 256 GB numerical array with non-atomic types
into another data structure with atomic versions of the same
type just so that you can apply atomic operations on it. So
one simply does an unsafe cast and hopes the compiler does not
break this.

If the non-atomic struct now has non-zero values in the padding, 
and the compiler would clear those automatically for "expected", 
you would create the problem of an infinite loop (this time 
for real).


Martin
  
Michael Matz Aug. 1, 2023, 3:54 p.m. UTC | #12
Hello,

On Mon, 31 Jul 2023, Martin Uecker wrote:

> >  Say you have a loop like so:
> > 
> > _Atomic T obj;
> > ...
> > T expected1, expected2, newval;
> > newval = ...;
> > expected1 = ...;
> > do {
> >   expected2 = expected1;
> >   if (atomic_compare_exchange_weak(&obj, &expected2, newval);
> >     break;
> >   expected1 = expected2;
> > } while (1);
> > 
> > As written this looks of course stupid, and you may say "don't do that", 
> > but internally the copies might result from temporaries (compiler 
> > generated or wrapper function arguments, or suchlike). 
> >  Now, while 
> > expected2 will contain the copied padding bits after the cmpxchg the 
> > copies to and from expected1 will possibly destroy them.  Either way I 
> > don't see why the above loop should be out-of-spec, so I can write it and 
> > expect it to proceed eventually (certainly when the _strong variant is 
> > used).  Any argument that would declare the above loop out-of-spec I would 
> > consider a defect in the spec.
> 
> It is "out-of-spec" for C in the sense that it can not be
> expected work with the semantics as specified in the C standard.

(I call that a defect.  See below)

> In practice, what the semantics specified using memcpy/memcmp
> allow one to do is to also apply atomic operations on non-atomic 
> types.  This is not guaranteed to work by the C standard, but
> in practice  people often have to do this.  For example, nobody
> is going to copy a 256 GB numerical array with non-atomic types
> into another data structure with atomic versions of the same
> type just so that you can apply atomic operations on it.
> So one simply does an unsafe cast and hopes the compiler does
> not break this.
> 
> If the non-atomic struct now has non-zero values in the padding, 
> and the compiler would clear those automatically for "expected", 
> you would create the problem of an infinite loop (this time 
> for real).

Only because cmpxchg is defined in terms of memcpy/memcmp.  If it were 
defined in terms of the == operator (obviously applied recursively 
member-wise for structs) and simple-assignment that wouldn't be a problem.  
In addition that would get rid of all discussion of what happens or 
doesn't happen with padding.  Introducing reliance on padding bits (which 
IMHO goes against some fundamental ideas of the C standard) has 
far-reaching consequences, see below.  The current definition of the 
atomic_cmpxchg is also inconsistent with the rest of the standard:

We have:

  ... (C is non-atomic variant of A) ...
  _Bool atomic_compare_exchange_strong(volatile A *object,
                                       C *expected, C desired);
  ... (is equivalent to atomic variant of:) 
  if (memcmp(object, expected, sizeof (*object)) == 0)
    { memcpy(object, &desired, sizeof (*object)); return true; }
  else
    { memcpy(expected, object, sizeof (*object)); return false; }

But we also have:

  The size, representation, and alignment of an atomic type need not be 
  the same as those of the corresponding unqualified type.

  (with later text only suggesting that at least for atomic integer 
  types these please be the same.  But here we aren't talking about
  integer types even.)

So, already the 'memcmp(object, expected, sizeof (*object)' may be 
undefined.  sizeof(*object) need not be the same as sizeof(*expected).
In particular the memcpy in the else branch might clobber memory outside 
*expected.

That alone should be sufficient to show that defining this all in terms of 
memcpy/memcmp is a bad idea.  But it also has other 
consequences: you can't copy (simple-assign) or compare (== operator) 
atomic values anymore reliably and expect the atomic_cmpxchg to work.  My 
example from earlier shows that you can't copy them, a similar one can be 
constructed for breaking ==.

But it goes further: you can also construct an example that shows an 
internal inconsistency just with using atomic_cmpxchg (of course, assume 
all this to run without concurrent accesses to the respective objects):

  _Atomic T obj;
  ...
  T expected, newval;
  expected = ...;
  newval = expected + 1;         // just to make it different
  atomic_store (&obj, expected);
  if (atomic_cmpxchg_strong (&obj, &expected, newval)) {
    /* Now we have: obj == newval.
       Do we also have memcmp(&obj,&newval)==0? */
    if (!atomic_cmpxchg_strong (&obj, &newval, expected)) {
      /* No, we can't rely on that!  */
      error("what's going on?");
    }
  } else {
    /* May happen, padding of expected may not be the same
       as in obj, even after atomic_store.  */
    error("WTH? a compare after a store doesn't even work?");
  }

So, even though cmpxchg is defined in terms of memcpy/memcmp, we still 
can't rely on anything after it succeeded (or failed).  Simply because the 
by-value passing of the 'desired' argument will have unknown padding 
(within the implementation of cmpxchg) that isn't necessarily the same as 
the newval object.

Now, about your suggestion of clearing or ignoring the padding bits at 
specific points:  Clearly with current standard language (being explicit 
about memcpy/memcmp and also within the text refering to 'contents of the 
memory pointed to by ...', unlike earlier versions that at least still 
talked about 'value of') padding bits cannot be ignored at the compare 
within cmpxchg.  Neither can anything be cleared from within cmpxchg (and 
that's even ignoring that *expected and *object might have completely 
different representations, as per above).

So, one idea was:

> A compiler could, for example, always clear the padding when
> initializing or storing atomic values.

But that doesn't help the memcmp: even if *object has 
cleared padding, *expected might not have (it's not of atomic type).  You 
explicitely ruled out ignoring the padding on *expected for the memcmp due 
to the above large-array example.  To that end you suggested:

> It might also clear the padding of the initial "expected", when it is 
> initialized or stored to.

But that amounts to magic, I don't see a way to do that: as far as the 
compiler is concerned it's just a random object of an arbitrary 
(non-atomic!) type coming from somewhere (that it's an argument to cmpxchg 
eventually might not be visible).  It would have to clear _all_ padding 
for all objects always, just because of the chance that it may eventually 
be passed to atomic_cmpxchg.  That quite clearly can't be the intention.

To be honest the whole passage that uses memcmp/memcpy within the 
definition of atomic_compare_exchange since C11 reads like a try to 
explain the semantics in simple terms, but failing to account for padding.  
Initially that wasn't such a problem because the normative text still 
said

   Atomically, compares the value pointed to by object for equality 
   with that in expected, and if true, replaces the value pointed to by 
   object with desired, and if false, updates the value in expected
   with the value pointed to by object.

Note: "value" not "value representation" or "memory pointed to".  It seems 
eventually people noticed an inconsistency between the memcpy/memcpy Note 
and the above text, and overcorrected this to also talk about "memory 
pointed to".  But that then elevates padding to something observable, and 
I think that is wrong and was done without sufficiently catering for the 
consequences.


Ciao,
Michael.
  
Joseph Myers Aug. 1, 2023, 4:54 p.m. UTC | #13
On Tue, 1 Aug 2023, Michael Matz via Gcc-patches wrote:

> Only because cmpxchg is defined in terms of memcpy/memcmp.  If it were 
> defined in terms of the == operator (obviously applied recursively 
> member-wise for structs) and simple-assignment that wouldn't be a problem.  

It also wouldn't work for floating point, where I think clearly the atomic 
operations should consider positive and negative zero as different, and 
should consider different DFP quantum exponents for the same real number 
as different - but should also consider the same NaN (same payload, same 
choice of quiet / signaling) as being the same.
  
Martin Uecker Aug. 1, 2023, 7:03 p.m. UTC | #14
Am Dienstag, dem 01.08.2023 um 15:54 +0000 schrieb Michael Matz:
> Hello,
> 
> On Mon, 31 Jul 2023, Martin Uecker wrote:
> 
> > >  Say you have a loop like so:
> > > 
> > > _Atomic T obj;
> > > ...
> > > T expected1, expected2, newval;
> > > newval = ...;
> > > expected1 = ...;
> > > do {
> > >   expected2 = expected1;
> > >   if (atomic_compare_exchange_weak(&obj, &expected2, newval);
> > >     break;
> > >   expected1 = expected2;
> > > } while (1);
> > > 
> > > As written this looks of course stupid, and you may say "don't do that", 
> > > but internally the copies might result from temporaries (compiler 
> > > generated or wrapper function arguments, or suchlike). 
> > >  Now, while 
> > > expected2 will contain the copied padding bits after the cmpxchg the 
> > > copies to and from expected1 will possibly destroy them.  Either way I 
> > > don't see why the above loop should be out-of-spec, so I can write it and 
> > > expect it to proceed eventually (certainly when the _strong variant is 
> > > used).  Any argument that would declare the above loop out-of-spec I would 
> > > consider a defect in the spec.
> > 
> > It is "out-of-spec" for C in the sense that it can not be
> > expected work with the semantics as specified in the C standard.
> 
> (I call that a defect.  See below)

This was extensively discussed in WG14 (before my time). In fact,
there was a defect report about the previous version defined in
terms of values and the wording was changed to memcmp / memcpy
operating on padding bytes (also to align with C++ at that time):

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2059.htm#dr_431
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1906.htm


> > In practice, what the semantics specified using memcpy/memcmp
> > allow one to do is to also apply atomic operations on non-atomic 
> > types.  This is not guaranteed to work by the C standard, but
> > in practice  people often have to do this.  For example, nobody
> > is going to copy a 256 GB numerical array with non-atomic types
> > into another data structure with atomic versions of the same
> > type just so that you can apply atomic operations on it.
> > So one simply does an unsafe cast and hopes the compiler does
> > not break this.
> > 
> > If the non-atomic struct now has non-zero values in the padding, 
> > and the compiler would clear those automatically for "expected", 
> > you would create the problem of an infinite loop (this time 
> > for real).
> 
> Only because cmpxchg is defined in terms of memcpy/memcmp. 

Yes, but this is intentional.

>  If it were 
> defined in terms of the == operator (obviously applied recursively 
> member-wise for structs) and simple-assignment that wouldn't be a problem. 

C has no == operator or any concept of struct equality. 

It would also cause implementation overhead and I guess
could cause severe performance issues when there several
padding bytes distributed over an object and you need to
jump over those when doing copying or doing comparisons.
(how do vectorization?)

> In addition that would get rid of all discussion of what happens or 
> doesn't happen with padding.  Introducing reliance on padding bits (which 
> IMHO goes against some fundamental ideas of the C standard) has 
> far-reaching consequences, see below. 

Working with representation bytes of objects is a rather 
fundamental property of C. That you can do this using
character pointers or that you can copy objects with
memcpy and that the result are compared with memcmp is
something I expect to work in C. 

>  The current definition of the 
> atomic_cmpxchg is also inconsistent with the rest of the standard:
> 
> We have:
> 
>   ... (C is non-atomic variant of A) ...
>   _Bool atomic_compare_exchange_strong(volatile A *object,
>                                        C *expected, C desired);
>   ... (is equivalent to atomic variant of:) 
>   if (memcmp(object, expected, sizeof (*object)) == 0)
>     { memcpy(object, &desired, sizeof (*object)); return true; }
>   else
>     { memcpy(expected, object, sizeof (*object)); return false; }
> 
> But we also have:
> 
>   The size, representation, and alignment of an atomic type need not be 
>   the same as those of the corresponding unqualified type.
> 
>   (with later text only suggesting that at least for atomic integer 
>   types these please be the same.  But here we aren't talking about
>   integer types even.)

Reading the old meeting minutes, it seems WG14 considered
the case that an atomic type could have a content part and
possibly a lock and you would compare only the content
part (with padding) and not the lock. But I agree, the
wording should be improved.


> 
> So, already the 'memcmp(object, expected, sizeof (*object)' may be 
> undefined.  sizeof(*object) need not be the same as sizeof(*expected).
> In particular the memcpy in the else branch might clobber memory outside 
> *expected.
> 
> That alone should be sufficient to show that defining this all in terms of 
> memcpy/memcmp is a bad idea.

I don't agree. But I agree the wording is not clear enough.


>   But it also has other 
> consequences: you can't copy (simple-assign) or compare (== operator) 
> atomic values anymore reliably and expect the atomic_cmpxchg to work.  My 
> example from earlier shows that you can't copy them, a similar one can be 
> constructed for breaking ==.

I am not sure I fully understand this.  

If you are not touching "expected" atomic_cmpxchg works as
intended. 

> But it goes further: you can also construct an example that shows an 
> internal inconsistency just with using atomic_cmpxchg (of course, assume 
> all this to run without concurrent accesses to the respective objects):
> 
>   _Atomic T obj;
>   ...
>   T expected, newval;
>   expected = ...;
>   newval = expected + 1;         // just to make it different
>   atomic_store (&obj, expected);
>   if (atomic_cmpxchg_strong (&obj, &expected, newval)) {
>     /* Now we have: obj == newval.
>        Do we also have memcmp(&obj,&newval)==0? */

There is not requirement for memcpy(...) == 0 because
the "newval" is passed in as a value. The standard also
does not talk about the "content of memory" of newval
while it does so for "obj" and "expected".

>     if (!atomic_cmpxchg_strong (&obj, &newval, expected)) {
>       /* No, we can't rely on that!  */
>       error("what's going on?");

Right, you can not rely on it. I personally do not find 
this surprising given the specification in C, but it
is certainly something one has to be aware of. 

But in a multi-threaded program, you could also not rely
on it, so I am not sure this is an issue.

>     }
>   } else {
>     /* May happen, padding of expected may not be the same
>        as in obj, even after atomic_store.  */
>     error("WTH? a compare after a store doesn't even work?");
>   }
> 
> So, even though cmpxchg is defined in terms of memcpy/memcmp, we still 
> can't rely on anything after it succeeded (or failed).  Simply because the 
> by-value passing of the 'desired' argument will have unknown padding 
> (within the implementation of cmpxchg) that isn't necessarily the same as 
> the newval object.

You can rely on expected being updated with the
representation of the "obj". So in a loop you can
rely on a successful store in the next iteration.
Also after a successful store the value stored in obj
and visible to other threads is the one in "desired".
This seems to cover the relevant use cases of cmpxchg.

> 
> Now, about your suggestion of clearing or ignoring the padding bits at 
> specific points:  Clearly with current standard language (being explicit 
> about memcpy/memcmp and also within the text refering to 'contents of the 
> memory pointed to by ...', unlike earlier versions that at least still 
> talked about 'value of') padding bits cannot be ignored at the compare 
> within cmpxchg.

Yes.

>   Neither can anything be cleared from within cmpxchg (and 
> that's even ignoring that *expected and *object might have completely 
> different representations, as per above).

cmpxchg can clear the padding of "desired" before copying
it into "obj"

> 
> So, one idea was:
> 
> > A compiler could, for example, always clear the padding when
> > initializing or storing atomic values.
> 
> But that doesn't help the memcmp: even if *object has 
> cleared padding, *expected might not have (it's not of atomic type).  You 
> explicitely ruled out ignoring the padding on *expected for the memcmp due 
> to the above large-array example.  

Yes, an initial "expected" is not guaranteed to have it, 
but if you read it via atomic_load or atomic_cmpxchg
it would have zero padding because all previous stores
to atomic types would have zero padding.

(One could also use memset to set the padding to zero
initially, if one really cares about spurious cycle).

> To that end you suggested:
> 
> > It might also clear the padding of the initial "expected", when it is 
> > initialized or stored to.
> 
> But that amounts to magic, I don't see a way to do that: as far as the 
> compiler is concerned it's just a random object of an arbitrary 
> (non-atomic!) type coming from somewhere (that it's an argument to cmpxchg 
> eventually might not be visible).  It would have to clear _all_ padding 
> for all objects always, just because of the chance that it may eventually 
> be passed to atomic_cmpxchg.  That quite clearly can't be the intention.

No, that wasn't may intention. But if it is a local variable
that is then passed to cmpxchg a compiler could clear the initial
padding as an optimization to prevent spurious cycles.

> 
> To be honest the whole passage that uses memcmp/memcpy within the 
> definition of atomic_compare_exchange since C11 reads like a try to 
> explain the semantics in simple terms, but failing to account for padding.  
> Initially that wasn't such a problem because the normative text still 
> said
>
>    Atomically, compares the value pointed to by object for equality 
>    with that in expected, and if true, replaces the value pointed to by 
>    object with desired, and if false, updates the value in expected
>    with the value pointed to by object.
> 
> Note: "value" not "value representation" or "memory pointed to".  It seems 
> eventually people noticed an inconsistency between the memcpy/memcpy Note 
> and the above text, and overcorrected this to also talk about "memory 
> pointed to".  But that then elevates padding to something observable, and 
> I think that is wrong and was done without sufficiently catering for the 
> consequences.

No, the new text was originally taking from C++ after discussing
this specific issue and then kept intentionally. The document
making this change is:

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1906.htm

Later WG21 then changed their opinion again, apparently after
people  forgot how  it was supposed to work (c.f the incorrect
example  in the WG21 document).

That people are misled by this, may  be a good reason
to change semantics, but I have to say that the possibility to
using atomic operations on existing types is far more important
in practice. (C++ has an ugly workaround for this).


Martin
  
Michael Matz Aug. 2, 2023, 12:25 p.m. UTC | #15
Hello,

On Tue, 1 Aug 2023, Joseph Myers wrote:

> > Only because cmpxchg is defined in terms of memcpy/memcmp.  If it were 
> > defined in terms of the == operator (obviously applied recursively 
> > member-wise for structs) and simple-assignment that wouldn't be a problem.  
> 
> It also wouldn't work for floating point, where I think clearly the atomic 
> operations should consider positive and negative zero as different, and 
> should consider different DFP quantum exponents for the same real number 
> as different - but should also consider the same NaN (same payload, same 
> choice of quiet / signaling) as being the same.

That is all true.  But the current wording can't work either.  It happily 
requires copying around memory between types of different representations 
and sizes, it makes padding observable behaviour, and due to that makes 
basic algebraic guarantees not be observed (after two values are checked 
equal with the predicates of the algrabra, they are not then in fact equal 
with predicates of the same algebra).


Ciao,
Michael.
  

Patch

--- gcc/testsuite/gcc.dg/torture/bitint-20.c.jj	2023-07-27 15:03:24.249234243 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-20.c	2023-07-27 15:03:24.249234243 +0200
@@ -0,0 +1,190 @@ 
+/* PR c/102989 */
+/* { dg-do run { target { bitint && int32plus } } } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) void
+test_135 (_BitInt(135) *p, _BitInt(39) *q, int i)
+{
+  p[3] = p[0] / p[1];
+  p[4] = p[2] / *q;
+  p[5] = p[i] % p[1 + i];
+  p[6] = p[2 + i] % q[i];
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) void
+test_192 (_BitInt(192) *p, _BitInt(62) *q, int i)
+{
+  p[3] = p[0] / p[1];
+  p[4] = p[2] / *q;
+  p[5] = p[i] % p[1 + i];
+  p[6] = p[2 + i] % q[i];
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) void
+test_575 (_BitInt(575) *p, _BitInt(125) *q, int i)
+{
+  p[3] = p[0] / p[1];
+  p[4] = p[2] / *q;
+  p[5] = p[i] % p[1 + i];
+  p[6] = p[2 + i] % q[i];
+}
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 135
+  static _BitInt(135) s135[] = {
+    11379259456099690377988816293288418659013wb,
+    -18507519859761926375595173102925837392wb,
+    -3487341362606172228883239379216537732914wb,
+    0, 0, 0, 0,
+    -18302253895694594136150902133229wb,
+    2910721282054679865681699220999829323779wb,
+    -17020765241462394475777917185801328548533wb,
+    0, 0, 0, 0,
+    18652952612120070842749648336935165019219wb,
+    -1wb,
+    -2328827552140837061029007041281845428062wb,
+    0, 0, 0, 0,
+    4586448317141516754412034429451793085778wb,
+    302326133131500453732826275685wb,
+    -13254392454085872482685218784341305341217wb,
+    0, 0, 0, 0,
+    -614wb,
+    16712959282178433685159137405wb,
+    15642262205867583373380008091954500325wb,
+    -27731730774wb,
+    0wb,
+    -75263829692564968827327018348wb,
+    -18302253895694594136150902133229wb,
+    -35227765213wb,
+    -18652952612120070842749648336935165019219wb,
+    112934753510539598517482519823570410wb,
+    0wb,
+    -3452wb,
+    15170532132wb,
+    -315580772716330297206790923436697746219wb,
+    126779339685614070998610275358wb,
+    -19wb
+  };
+  static _BitInt(39) s39[] = {
+    -208660914188wb,
+    226148009090wb,
+    -20621wb,
+    42wb
+  };
+  for (int i = 0; i < 4; ++i)
+    {
+      test_135 (s135 + 7 * i, s39 + i, 0);
+      for (int j = 0; j < 4; ++j)
+	if (s135[7 * i + 3 + j] != s135[7 * 4 + 4 * i + j])
+	  __builtin_abort ();
+    }
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static _BitInt(192) s192[] = {
+    -2179289138164349400542345646041597314396798352437085702063wb,
+    -79910962432789464031897580939163427724139130993wb,
+    -3036473005246707700116012885952806814462013063553154406939wb,
+    0, 0, 0, 0,
+    641265343041674918120574087098wb,
+    -72968858271155659573911879940731439944647195520825153965wb,
+    2701717062040203003887103138051480805185032453926240220524wb,
+    0, 0, 0, 0,
+    -841691204113630961349106466971783187865820857103239354134wb,
+    3wb,
+    -87971197399776002207343095550078219wb,
+    0, 0, 0, 0,
+    1975530920339244356926809414608241391203379490466789216052wb,
+    -1491609620853264847219953011450130087411551266523269wb,
+    -1446625088493520499379069533952596205wb,
+    0, 0, 0, 0,
+    27271466539wb,
+    1706692225050149442221770028739016905019wb,
+    -79245495764706738784157700565393118980948358836wb,
+    -1501915295097973757wb,
+    0wb,
+    4771029735868622050569106388224414265428wb,
+    641265343041674918120574087098wb,
+    333711124246457812wb,
+    -280563734704543653783035488990594395955273619034413118044wb,
+    -11314906111712376578wb,
+    -2wb,
+    -2479408421589529wb,
+    -1324428wb,
+    -11301758503855628901398980734004657wb,
+    1373411796501852981487559368499793073469647909100920wb,
+    -109wb
+  };
+  static _BitInt(62) s62[] = {
+    -1779156757544544378wb,
+    566275460772898254wb,
+    7774805776666105wb,
+    128wb
+  };
+  for (int i = 0; i < 4; ++i)
+    {
+      test_192 (s192 + 7 * i, s62 + i, 0);
+      for (int j = 0; j < 4; ++j)
+	if (s192[7 * i + 3 + j] != s192[7 * 4 + 4 * i + j])
+	  __builtin_abort ();
+    }
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static _BitInt(575) s575[] = {
+    -46295454425650349106237210715560972814514774894381316941718135777652722445546437187679065682949497046056192846156902024414635126978980056110286059194406244047429103543013567wb,
+    8168911130831183937943637579544406842555974190640492967747336926965525847745100099776294868623258477082653103560744709659980631459947315392636659059426713543595666476280533wb,
+    -35562636740560878776057515364478086997557966107967281638887951768166903062463010597490396666936792092197907362468852658846219038084825902297279012227062238709275022706654710wb,
+    0, 0, 0, 0,
+    8943720225181967953483417970wb,
+    -5686323784402794959708902425053022672027524027657863695096812917030055678499948429234881641591266594283291408732579354863768974925810198523510127753699305465302067821wb,
+    45545655058039702583745674825335158540648677810736798412180196426599514263661272184545433928331514411963531127261916383264154901783937763805071704477825859668914160192614845wb,
+    0, 0, 0, 0,
+    50424935157410302671220896696045811569932594372403814676921199727418115659236492512040645301161966980307514350263276765199536014825688175664310129375564263158984wb,
+    -7wb,
+    -1570414268527860342275074326241251266943768106178059338676497087694509262100926288185672140837995480549018141550944901112529623354869552332831768648238175848946606383367442wb,
+    0, 0, 0, 0,
+    33743599683183012321962199340752013311691198627837686174760810997243129260923502613536719907475631360213576483574943246620765095970215288302282988013296681749186377007244629wb,
+    -241344364975185779312145695113143874342953936016290256207617251781961618409457239212648767218870128884542434148wb,
+    264442076257762743508952577439304094891926651736030778233607159152726518015778933421402285405943871924053070093963838538880775338376789919798084050039162wb,
+    0, 0, 0, 0,
+    -5wb,
+    5102554304763340573123278154007968305825944534675387388100485979831828339912883404866537264221784637582259122678928387415569088293221166wb,
+    -5450898771494429416519022817838938601734903941178852102981451142825093206820936688797591339833204660642927328353178476114731969679243479147102763897272676329450771161610902wb,
+    -27841416716804082903535753217607970wb,
+    0wb,
+    2845786405948228702992300882035725001599103765023382470517698884483710061812613500615722877137078798659301720051530203483092161498954792wb,
+    8943720225181967953483417970wb,
+    14857023063025350938701283170104334549wb,
+    -7203562165344328953031556670863687367133227767486259239560171389631159379890927501720092185880280997186787764323325252171362287832241167952044304196509180451283wb,
+    193782868826267453015550702420724985315443493285153355021508389301944425453072371810496604181725982879795555170278476391923261741289049794434571591514767wb,
+    3wb,
+    -5203319495353646668wb,
+    -139815154526820696318711149230487844769233301636772309388492158wb,
+    -323204355193745164479045143032958628560847774063940216640778815817376770038460708119250193248428869489076997487384931038wb,
+    180305213672139436589458419226578301650781616412684462286468318018185661952458180767935939240752755560277833245wb,
+    316649622804067950787613592683370wb
+  };
+  static _BitInt(125) s125[] = {
+    -6969575357064287919545125499931812390wb,
+    16004593655673074838414651760840291513wb,
+    -8103989160857077722wb,
+    -818188468095495446473587377169784wb
+  };
+  for (int i = 0; i < 4; ++i)
+    {
+      test_575 (s575 + 7 * i, s125 + i, 0);
+      for (int j = 0; j < 4; ++j)
+	if (s575[7 * i + 3 + j] != s575[7 * 4 + 4 * i + j])
+	  __builtin_abort ();
+    }
+#endif
+}
--- gcc/testsuite/gcc.dg/torture/bitint-21.c.jj	2023-07-27 15:03:24.246234285 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-21.c	2023-07-27 15:03:24.246234285 +0200
@@ -0,0 +1,282 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __FLT_MANT_DIG__ == 24
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) _BitInt(135)
+testflt_135 (float d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(135)
+testfltu_135 (float d)
+{
+  return d;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) _BitInt(192)
+testflt_192 (float d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(192)
+testfltu_192 (float d)
+{
+  return d;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) _BitInt(575)
+testflt_575 (float d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(575)
+testfltu_575 (float d)
+{
+  return d;
+}
+#endif
+#endif
+
+#if __DBL_MANT_DIG__ == 53
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) _BitInt(135)
+testdbl_135 (double d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(135)
+testdblu_135 (double d)
+{
+  return d;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) _BitInt(192)
+testdbl_192 (double d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(192)
+testdblu_192 (double d)
+{
+  return d;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) _BitInt(575)
+testdbl_575 (double d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(575)
+testdblu_575 (double d)
+{
+  return d;
+}
+#endif
+#endif
+
+int
+main ()
+{
+#if __FLT_MANT_DIG__ == 24
+#if __BITINT_MAXWIDTH__ >= 135
+  static float flt_135[] = {
+    0.25f, 0.0f, 1.0f, -42.0f, 16777215.25f,
+    -50855501824.5f, 39580962846540824576.0f,
+    -122147759335346835551823516808712814592.0f,
+    -85070591730234615865843651857942052864.0f
+  };
+  static _BitInt(135) fltr_135[] = {
+    0wb, 0wb, 1wb, -42wb, 16777215wb,
+    -50855501824wb, 39580962846540824576wb,
+    -122147759335346835551823516808712814592wb,
+    -85070591730234615865843651857942052864wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testflt_135 (flt_135[i]) != fltr_135[i])
+      __builtin_abort ();
+  static float fltu_135[] = {
+    0.125f, 0.0f, 1.0f, 42.59375f, 16777215.75f,
+    397530272.5f, 1557145973265213792232550652968960.0f,
+    69722182498815269047577928656018735104.0f
+  };
+  static unsigned _BitInt(135) fltur_135[] = {
+    0uwb, 0uwb, 1uwb, 42uwb, 16777216uwb,
+    397530272uwb, 1557145973265213792232550652968960uwb,
+    69722182498815269047577928656018735104uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testfltu_135 (fltu_135[i]) != fltur_135[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static float flt_192[] = {
+    0.625f, 0.0f, 1.0f, -42.0f, 16777215.25f,
+    -166724322197504.5f, 7557890186859550768856301568.0f,
+    6614377725485260848635133905887821824.0f,
+    -85070591730234615865843651857942052864.0f
+  };
+  static _BitInt(192) fltr_192[] = {
+    0wb, 0wb, 1wb, -42wb, 16777215wb,
+    -166724322197504wb, 7557890186859550768856301568wb,
+    6614377725485260848635133905887821824wb,
+    -85070591730234615865843651857942052864wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testflt_192 (flt_192[i]) != fltr_192[i])
+      __builtin_abort ();
+  static float fltu_192[] = {
+    __FLT_MIN__, 0.0f, 1.0f, 42.125f, 16777216.75f,
+    2197600337920.75f, 4591683053408742366929307227985543168.0f,
+    89668786387864080590151097276117811200.0f
+  };
+  static unsigned _BitInt(192) fltur_192[] = {
+    0uwb, 0uwb, 1uwb, 42uwb, 16777216uwb,
+    2197600337920uwb, 4591683053408742366929307227985543168uwb,
+    89668786387864080590151097276117811200uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testfltu_192 (fltu_192[i]) != fltur_192[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static float flt_575[] = {
+    0.0001f, 0.0f, 1.0f, -28.0f, 16777214.75f,
+    -1321998852554752.5f, 3447217350995641328695097279119360.0f,
+    -153684583933125564944797950598195445760.0f,
+    -6614377725485260848635133905887821824.0f
+  };
+  static _BitInt(575) fltr_575[] = {
+    0wb, 0wb, 1wb, -28wb, 16777215wb,
+    -1321998852554752wb, 3447217350995641328695097279119360wb,
+    -153684583933125564944797950598195445760wb,
+    -6614377725485260848635133905887821824wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testflt_575 (flt_575[i]) != fltr_575[i])
+      __builtin_abort ();
+  static float fltu_575[] = {
+    4.0f * __FLT_MIN__, 0.0f, 1.0f, 38.125f, 16777210.75f,
+    450604433408.75f, 49420393052787309452540595771398946816.0f,
+    144076816645080570490809349637635309568.0f
+  };
+  static unsigned _BitInt(575) fltur_575[] = {
+    0uwb, 0uwb, 1uwb, 38uwb, 16777211uwb,
+    450604433408uwb, 49420393052787309452540595771398946816uwb,
+    144076816645080570490809349637635309568uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testfltu_575 (fltu_575[i]) != fltur_575[i])
+      __builtin_abort ();
+#endif
+#endif
+#if __DBL_MANT_DIG__ == 53
+#if __BITINT_MAXWIDTH__ >= 135
+  static double dbl_135[] = {
+    0.25, 0.0, 1.0, -42.0, 4294967295.25,
+    -600381955574889.5, 31830517255028909053694705664.0,
+    -18738990071541038357046558935673124945920.0,
+    -21778071482940061661655974875633165533184.0
+  };
+  static _BitInt(135) dblr_135[] = {
+    0wb, 0wb, 1wb, -42wb, 4294967295wb,
+    -600381955574889wb, 31830517255028909053694705664wb,
+    -18738990071541038357046558935673124945920wb,
+    -21778071482940061661655974875633165533183wb - 1wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testdbl_135 (dbl_135[i]) != dblr_135[i])
+      __builtin_abort ();
+  static double dblu_135[] = {
+    0.125, 0.0, 1.0, 42.59375, 4294967295.75,
+    1379919377114330.5, 1887176628826898072984354816.0,
+    28122698032432725461429202074509590396928.0
+  };
+  static unsigned _BitInt(135) dblur_135[] = {
+    0uwb, 0uwb, 1uwb, 42uwb, 4294967295uwb,
+    1379919377114330uwb, 1887176628826898072984354816uwb,
+    28122698032432725461429202074509590396928uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testdblu_135 (dblu_135[i]) != dblur_135[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static double dbl_192[] = {
+    0.625, 0.0, 1.0, -42.0, 4294967295.25,
+    -334692618508390720.5, 7241713824636372052614321786924022698463985664.0,
+    1051470826442514757151114043324296190023320100185399361536.0,
+    -3138550867693340381917894711603833208051177722232017256448.0
+  };
+  static _BitInt(192) dblr_192[] = {
+    0wb, 0wb, 1wb, -42wb, 4294967295wb,
+    -334692618508390720wb, 7241713824636372052614321786924022698463985664wb,
+    1051470826442514757151114043324296190023320100185399361536wb,
+    -3138550867693340381917894711603833208051177722232017256447wb - 1wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testdbl_192 (dbl_192[i]) != dblr_192[i])
+      __builtin_abort ();
+  static double dblu_192[] = {
+    __DBL_MIN__, 0.0, 1.0, 42.125, 4294967296.75,
+    85543274084479312.75, 1452517026416706854711122198528.0,
+    4878159368183578289135952951143197426988727705359645409280.0
+  };
+  static unsigned _BitInt(192) dblur_192[] = {
+    0uwb, 0uwb, 1uwb, 42uwb, 4294967296uwb,
+    85543274084479312uwb, 1452517026416706854711122198528uwb,
+    4878159368183578289135952951143197426988727705359645409280uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testdblu_192 (dblu_192[i]) != dblur_192[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static double dbl_575[] = {
+    0.0001, 0.0, 1.0, -28.0, 4294967294.75,
+    -37518052491018912.5, 103740344328578397848785318842252129922803939603530145015162908477052192630505472.0,
+    -60264112735379285992549557294906950572505306720710356591257742566415478531569283626542380634430345616295459560427283714375540825055746407845009719778430303250931745441185792.0,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174784.0
+  };
+  static _BitInt(575) dblr_575[] = {
+    0wb, 0wb, 1wb, -28wb, 4294967294wb,
+    -37518052491018912wb, 103740344328578397848785318842252129922803939603530145015162908477052192630505472wb,
+    -60264112735379285992549557294906950572505306720710356591257742566415478531569283626542380634430345616295459560427283714375540825055746407845009719778430303250931745441185792wb,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testdbl_575 (dbl_575[i]) != dblr_575[i])
+      __builtin_abort ();
+  static double dblu_575[] = {
+    4.0 * __DBL_MIN__, 0.0, 1.0, 38.125, 4294967297.75,
+    138240328005104064.75, 1588129215384992270224118343146332410113351482118715170651778867930903010675691494429363974899842924150784.0,
+    106390366882040443685518677989907085524608028099417390750037507495093586319031581000179209552004867195248003952212636389496136628539779816025838629984567658036669448510767104.0
+  };
+  static unsigned _BitInt(575) dblur_575[] = {
+    0uwb, 0uwb, 1uwb, 38uwb, 4294967297uwb,
+    138240328005104064uwb, 1588129215384992270224118343146332410113351482118715170651778867930903010675691494429363974899842924150784uwb,
+    106390366882040443685518677989907085524608028099417390750037507495093586319031581000179209552004867195248003952212636389496136628539779816025838629984567658036669448510767104uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testdblu_575 (dblu_575[i]) != dblur_575[i])
+      __builtin_abort ();
+#endif
+#endif
+}
--- gcc/testsuite/gcc.dg/torture/bitint-22.c.jj	2023-07-27 15:03:24.249234243 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-22.c	2023-07-27 15:03:24.249234243 +0200
@@ -0,0 +1,282 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __LDBL_MANT_DIG__ == 64
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) _BitInt(135)
+testldbl_135 (long double d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(135)
+testldblu_135 (long double d)
+{
+  return d;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) _BitInt(192)
+testldbl_192 (long double d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(192)
+testldblu_192 (long double d)
+{
+  return d;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) _BitInt(575)
+testldbl_575 (long double d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(575)
+testldblu_575 (long double d)
+{
+  return d;
+}
+#endif
+#endif
+
+#if __FLT128_MANT_DIG__ == 113
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) _BitInt(135)
+testflt128_135 (_Float128 d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(135)
+testflt128u_135 (_Float128 d)
+{
+  return d;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) _BitInt(192)
+testflt128_192 (_Float128 d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(192)
+testflt128u_192 (_Float128 d)
+{
+  return d;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) _BitInt(575)
+testflt128_575 (_Float128 d)
+{
+  return d;
+}
+
+__attribute__((noipa)) unsigned _BitInt(575)
+testflt128u_575 (_Float128 d)
+{
+  return d;
+}
+#endif
+#endif
+
+int
+main ()
+{
+#if __LDBL_MANT_DIG__ == 64
+#if __BITINT_MAXWIDTH__ >= 135
+  static long double ldbl_135[] = {
+    0.25L, 0.0L, 1.0L, -42.0L, 4294967295.25L,
+    -8790480341948727187.25L, 27274375615880435204096.0L,
+    -14925443517338257613013233930892304449536.0L,
+    -21778071482940061661655974875633165533184.0L
+  };
+  static _BitInt(135) ldblr_135[] = {
+    0wb, 0wb, 1wb, -42wb, 4294967295wb,
+    -8790480341948727187wb, 27274375615880435204096wb,
+    -14925443517338257613013233930892304449536wb,
+    -21778071482940061661655974875633165533183wb - 1wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testldbl_135 (ldbl_135[i]) != ldblr_135[i])
+      __builtin_abort ();
+  static long double ldblu_135[] = {
+    0.125L, 0.0L, 1.0L, 42.59375L, 4294967295.75L,
+    176563931524327024.5L, 33864941055480177570480471932928.0L,
+    25454535165593017203571842988709209178112.0L
+  };
+  static unsigned _BitInt(135) ldblur_135[] = {
+    0uwb, 0uwb, 1uwb, 42uwb, 4294967295uwb,
+    176563931524327024uwb, 33864941055480177570480471932928uwb,
+    25454535165593017203571842988709209178112uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testldblu_135 (ldblu_135[i]) != ldblur_135[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static long double ldbl_192[] = {
+    0.625L, 0.0L, 1.0L, -42.0L, 4294967295.25L,
+    -5824742198306330891.5L, 440458331210868742661519441920.0L,
+    1835666805014205039814897225189119947560942436848001613824.0L,
+    -3138550867693340381917894711603833208051177722232017256448.0L
+  };
+  static _BitInt(192) ldblr_192[] = {
+    0wb, 0wb, 1wb, -42wb, 4294967295wb,
+    -5824742198306330891wb, 440458331210868742661519441920wb,
+    1835666805014205039814897225189119947560942436848001613824wb,
+    -3138550867693340381917894711603833208051177722232017256447wb - 1wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testldbl_192 (ldbl_192[i]) != ldblr_192[i])
+      __builtin_abort ();
+  static long double ldblu_192[] = {
+    __LDBL_MIN__, 0.0L, 1.0L, 42.125L, 4294967296.75L,
+    2076918887405157419.75L, 20675944534182826922963677915852149395069559898112.0L,
+    5501434424609388038261967254007295028886638351806353113088.0L
+  };
+  static unsigned _BitInt(192) ldblur_192[] = {
+    0uwb, 0uwb, 1uwb, 42uwb, 4294967296uwb,
+    2076918887405157419uwb, 20675944534182826922963677915852149395069559898112uwb,
+    5501434424609388038261967254007295028886638351806353113088uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testldblu_192 (ldblu_192[i]) != ldblur_192[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static long double ldbl_575[] = {
+    0.0001L, 0.0L, 1.0L, -28.0L, 4294967294.75L,
+    -3665832965020207456.5L, 163698889538251840454153874702336.0L,
+    32915174451748642699300864037265677114762093753017270154115822402734463611341115095984060833654391570465670441530007982951775959694729040694137686724336684263404019031998464.0L,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174784.0L
+  };
+  static _BitInt(575) ldblr_575[] = {
+    0wb, 0wb, 1wb, -28wb, 4294967294wb,
+    -3665832965020207456wb, 163698889538251840454153874702336wb,
+    32915174451748642699300864037265677114762093753017270154115822402734463611341115095984060833654391570465670441530007982951775959694729040694137686724336684263404019031998464wb,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testldbl_575 (ldbl_575[i]) != ldblr_575[i])
+      __builtin_abort ();
+  static long double ldblu_575[] = {
+    4.0L * __LDBL_MIN__, 0.0L, 1.0L, 38.125L, 4294967297.75L,
+    1378703406647015633.75L, 611519358004879551476944320883148018860550235384446976.0L,
+    115943866857281393364910134541262519802574312323472821552898049002204954780753923929784955305825114286696121504922573067409422635510048274769753298552619702526028834918105088.0L
+  };
+  static unsigned _BitInt(575) ldblur_575[] = {
+    0uwb, 0uwb, 1uwb, 38uwb, 4294967297uwb,
+    1378703406647015633uwb, 611519358004879551476944320883148018860550235384446976uwb,
+    115943866857281393364910134541262519802574312323472821552898049002204954780753923929784955305825114286696121504922573067409422635510048274769753298552619702526028834918105088uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testldblu_575 (ldblu_575[i]) != ldblur_575[i])
+      __builtin_abort ();
+#endif
+#endif
+#if __FLT128_MANT_DIG__ == 113
+#if __BITINT_MAXWIDTH__ >= 135
+  static _Float128 flt128_135[] = {
+    0.25F128, 0.0F128, 1.0F128, -42.0F128, 4294967295.25F128,
+    -622114258022893415468272077014949.5F128, 6846686534183872435237780851340978176.0F128,
+    -18109992041001989671440396535501724581888.0F128,
+    -21778071482940061661655974875633165533184.0F128
+  };
+  static _BitInt(135) flt128r_135[] = {
+    0wb, 0wb, 1wb, -42wb, 4294967295wb,
+    -622114258022893415468272077014949wb, 6846686534183872435237780851340978176wb,
+    -18109992041001989671440396535501724581888wb,
+    -21778071482940061661655974875633165533183wb - 1wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testflt128_135 (flt128_135[i]) != flt128r_135[i])
+      __builtin_abort ();
+  static _Float128 flt128u_135[] = {
+    0.125F128, 0.0F128, 1.0F128, 42.59375F128, 4294967295.75F128,
+    3866883549893778868343627501393297.5F128, 1884508847679496004639718578196282112.0F128,
+    40418154190724512480670668005754087145472.0F128
+  };
+  static unsigned _BitInt(135) flt128ur_135[] = {
+    0uwb, 0uwb, 1uwb, 42uwb, 4294967295uwb,
+    3866883549893778868343627501393297uwb, 1884508847679496004639718578196282112uwb,
+    40418154190724512480670668005754087145472uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testflt128u_135 (flt128u_135[i]) != flt128ur_135[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static _Float128 flt128_192[] = {
+    0.625F128, 0.0F128, 1.0F128, -42.0F128, 4294967295.25F128,
+    -2985198467222342042164811285508981.5F128, 431282768955649236431442335280406747022360576.0F128,
+    1589969577168452878096502186670522088231011726426596442112.0F128,
+    -3138550867693340381917894711603833208051177722232017256448.0F128
+  };
+  static _BitInt(192) flt128r_192[] = {
+    0wb, 0wb, 1wb, -42wb, 4294967295wb,
+    -2985198467222342042164811285508981wb, 431282768955649236431442335280406747022360576wb,
+    1589969577168452878096502186670522088231011726426596442112wb,
+    -3138550867693340381917894711603833208051177722232017256447wb - 1wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testflt128_192 (flt128_192[i]) != flt128r_192[i])
+      __builtin_abort ();
+  static _Float128 flt128u_192[] = {
+    __FLT128_MIN__, 0.0F128, 1.0F128, 42.125F128, 4294967296.75F128,
+    1198221816583045676753413578483973.75F128, 321058543109670204450967161534914741927936.0F128,
+    4124250833671183507048495617931376186682553019928355536896.0F128
+  };
+  static unsigned _BitInt(192) flt128ur_192[] = {
+    0uwb, 0uwb, 1uwb, 42uwb, 4294967296uwb,
+    1198221816583045676753413578483973uwb, 321058543109670204450967161534914741927936uwb,
+    4124250833671183507048495617931376186682553019928355536896uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testflt128u_192 (flt128u_192[i]) != flt128ur_192[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static _Float128 flt128_575[] = {
+    0.0001F128, 0.0F128, 1.0F128, -28.0F128, 4294967294.75F128,
+    -4434536963340205213805292449887836.5F128, 7798956314177801818163892326325236647148010864640.0F128,
+    -48379475169482975928082617475070980956970510451882414558095669485086407691242420689411465910847147042640064381848760072045866350077715681395831023828798188292450661613699072.0F128,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174784.0F128
+  };
+  static _BitInt(575) flt128r_575[] = {
+    0wb, 0wb, 1wb, -28wb, 4294967294wb,
+    -4434536963340205213805292449887836wb, 7798956314177801818163892326325236647148010864640wb,
+    -48379475169482975928082617475070980956970510451882414558095669485086407691242420689411465910847147042640064381848760072045866350077715681395831023828798188292450661613699072wb,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1wb
+  };
+  for (int i = 0; i < 9; ++i)
+    if (testflt128_575 (flt128_575[i]) != flt128r_575[i])
+      __builtin_abort ();
+  static _Float128 flt128u_575[] = {
+    4.0F128 * __FLT128_MIN__, 0.0F128, 1.0F128, 38.125F128, 4294967297.75F128,
+    1286565442597535616086070715374552.75F128, 2888274376848382435313359223769917404575136171432777745913780227423600640.0F128,
+    101012352069182509789055890148950528106809264092697629422634347377509770791198015780931797016594366657511165718215124632216959526129296364564413818230848005073384975475146752.0F128
+  };
+  static unsigned _BitInt(575) flt128ur_575[] = {
+    0uwb, 0uwb, 1uwb, 38uwb, 4294967297uwb,
+    1286565442597535616086070715374552uwb, 2888274376848382435313359223769917404575136171432777745913780227423600640uwb,
+    101012352069182509789055890148950528106809264092697629422634347377509770791198015780931797016594366657511165718215124632216959526129296364564413818230848005073384975475146752uwb
+  };
+  for (int i = 0; i < 8; ++i)
+    if (testflt128u_575 (flt128u_575[i]) != flt128ur_575[i])
+      __builtin_abort ();
+#endif
+#endif
+}
--- gcc/testsuite/gcc.dg/torture/bitint-23.c.jj	2023-07-27 15:03:24.245234299 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-23.c	2023-07-27 15:03:24.245234299 +0200
@@ -0,0 +1,804 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __FLT_MANT_DIG__ == 24
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) float
+testflt_135 (_BitInt(135) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) float
+testfltu_135 (unsigned _BitInt(135) b)
+{
+  return b;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) float
+testflt_192 (_BitInt(192) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) float
+testfltu_192 (unsigned _BitInt(192) b)
+{
+  return b;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) float
+testflt_575 (_BitInt(575) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) float
+testfltu_575 (unsigned _BitInt(575) b)
+{
+  return b;
+}
+#endif
+#endif
+
+#if __DBL_MANT_DIG__ == 53
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) double
+testdbl_135 (_BitInt(135) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) double
+testdblu_135 (unsigned _BitInt(135) b)
+{
+  return b;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) double
+testdbl_192 (_BitInt(192) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) double
+testdblu_192 (unsigned _BitInt(192) b)
+{
+  return b;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) double
+testdbl_575 (_BitInt(575) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) double
+testdblu_575 (unsigned _BitInt(575) b)
+{
+  return b;
+}
+#endif
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 135
+  static _BitInt(135) s_135[] = {
+    -39242093wb,
+    -36246971635108657318127321wb,
+    -816440703352wb,
+    8409360wb,
+    231875wb,
+    -1859wb,
+    8123250453541347379290840008816194983wb,
+    42642091wb,
+    -2499664813007708583619356686wb,
+    -14022533493907734339644wb,
+    737816709430180009697449492wb,
+    3094418595787172583521548578719419wb,
+    84096wb,
+    -3856393637064417wb,
+    5494wb,
+    -7227655824382622730861wb,
+    185250722103742953wb,
+    -266695839223233222300219080587185431wb,
+    124wb,
+    -4540724906728461994579131745203067wb,
+    -34474123wb,
+    6171186wb,
+    -1738448518309495501564259945530043942wb,
+    3714wb,
+    22759310366655438105064084505115489wb,
+    -461wb,
+    -1891475049610273521994429918325638525836wb,
+    -350wb,
+    3721759411106519959861226774340wb,
+    -42485872965031409753wb,
+    4362279409022137273490486629950wb,
+    521928664204421037572709995195346211111wb,
+    -50129wb,
+    -21525556783117336078661729wb
+  };
+  static unsigned _BitInt(135) u_135[] = {
+    773802493804221964748670742461281016363uwb,
+    897485218654369665002411485681173uwb,
+    37306898634990773758633uwb,
+    3uwb,
+    920156uwb,
+    15230973698181139105641901258312096uwb,
+    1383843491123931387484696uwb,
+    143810081711544975903357370071668200uwb,
+    83615891310230331473978uwb,
+    1239150390uwb,
+    39792042288uwb,
+    20985035121604uwb,
+    3700707uwb,
+    14510535740825uwb,
+    5675982879048653163399531637816917uwb,
+    593909622129190124122830uwb,
+    413008891327830587264uwb,
+    34694483328uwb,
+    592129uwb,
+    2649uwb,
+    154468451808267466822214091328849uwb,
+    8905088171048376399858691570634230197204uwb,
+    456uwb,
+    12101uwb,
+    5879086272uwb,
+    115170058487623uwb,
+    2274163249406113742515726136586945854500uwb,
+    63923152267905666653uwb,
+    624302860090054295150365837280525227924uwb,
+    9uwb,
+    5703520721951508439418uwb,
+    44653119094uwb,
+    1440439605268989101uwb,
+    3496654014361uwb
+  };
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static _BitInt(192) s_192[] = {
+    81945579384314684613279565479277935940wb,
+    1640150770700583136800158704601080wb,
+    432402469012491481987292073086668wb,
+    -15369197386440508323548800500962985157137866798390wb,
+    217705797486262wb,
+    1wb,
+    -150837356854711044278780637wb,
+    1247354027519369533750440146304wb,
+    -700073531555662209687924602081wb,
+    -441651351073606706893667405889558445894wb,
+    -743993151249791392844844248857961054wb,
+    1681039wb,
+    -170386616439159353410812029301398243129730wb,
+    -97703172400304820221345002831889wb,
+    9wb,
+    7277656199366069102639319241893wb,
+    7201222364wb,
+    -4671533967546296507223686237333335wb,
+    13311155734490577635922550wb,
+    76150533189365685907637983428512213977569647wb,
+    -283560863483321465221194695455688610811wb,
+    6438368552004797088499844257634549000496626110080371wb,
+    1122038765213390728664343086041576wb,
+    -9541613313421359977755878156940wb,
+    21551012076757076795102244535269250wb,
+    -4794294047755173531367558272wb,
+    -5708612827808554221wb,
+    -2649648007071280662902443553973167294046518180wb,
+    -35698660478241255546377wb,
+    -79587921140918wb,
+    469393710173925646wb,
+    -261330983098092746969723637867599382044980841179747207wb,
+    -115wb,
+    -1717706681396wb
+  };
+  static unsigned _BitInt(192) u_192[] = {
+    87197051833867272589618945858714291675632402028uwb,
+    175207476610687227705633653396153452205075322355946uwb,
+    289472685412214318981767004188uwb,
+    58352315342320048378103056601781218026976uwb,
+    68512267071922032916894194298300228491490143452269uwb,
+    8654067584750856592691725728280108682858075uwb,
+    57027948061283099317671673937496946487124629uwb,
+    512829256101uwb,
+    8815296701808550493421309771596155666520uwb,
+    1918805208198312310092547265227uwb,
+    99680639255733807uwb,
+    313647272226958893709907781719uwb,
+    534434342549592762863366619879590694414818uwb,
+    1751643652514709uwb,
+    24084146046683127013882581681582087uwb,
+    1282076uwb,
+    13590701668411111769uwb,
+    62207549230439503653uwb,
+    144040025133692457990548614076288499046uwb,
+    11981724905403945793356785358565398049196880116uwb,
+    1823479497818478859136796209626920064416489979129893695uwb,
+    4649uwb,
+    2095541338428713427585867932062430293488017906261402uwb,
+    605377488765896342050766363050545164888333863362uwb,
+    11488350477184223uwb,
+    9492972359709013710789022084605392630683565515935199uwb,
+    36826148417259uwb,
+    554404239122129842026250702689uwb,
+    2804528919100uwb,
+    127uwb,
+    66823885107232870336040073990324uwb,
+    297736625249uwb,
+    3701132312864550550157874952341371502832960625370598966uwb,
+    107247048428uwb
+  };
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static _BitInt(575) s_575[] = {
+    822555268170764275096048134868384963633463468104839796862654006268369616wb,
+    -960580267694575830808697063169243963045681635800151938720065734940592300657700227419337766780029829446319203wb,
+    33504080263976494448954627475165765154890874061543914469206217657999706310163279811015042121096338719830090426757797138233202615461wb,
+    275983725374553564148936957707321552749wb,
+    5534912144897227754137156977371639235252437172582938580045103986268272085395760563838753817115093434280932847973705994570261258933419373885658991359441723005813683395590541wb,
+    1412920302762671055711845665320769771488824036206881359103417821581950493952853265134760513685359011001836948515905971331797139790wb,
+    -262974997977953570994865210107604152900839198803859287819970850481583440338320059wb,
+    -92488905333378799268618025132022462336176863903734682501838771365453998891689279398wb,
+    242604167696163732697906496386839396751068wb,
+    -3523803651131338645439245946293wb,
+    -5147220779398204849222374563179412010462379234108857688330486391319694172748210918710342389194957287070617133280194810193962683650761347126311504766504260691wb,
+    -126995956651641937332005246092202755154992252553028943468563459072746155379181900761169956344678911600wb,
+    8137926360495wb,
+    -15994393111836746332671329788635258wb,
+    -277068516868681202554828866807401284583187899477211188256772654837767448404666578906477389363058609157862574wb,
+    12643256666940489874033990964997310860090310878838229112053311027168830831623703103010815387wb,
+    197250790460297242975596746662998763328365874997wb,
+    2003391279347376998472wb,
+    -199877387236416475658211887841938073691092213166438343739wb,
+    683783725793437346966376731991835336458591392078548990419792641719902684445391913394174240265031277360362886303597899811253111402611797905136669wb,
+    13527430925075101894748577029275389339063875642859674079897983403256wb,
+    539267000300803493510458136103246878203019746178696339759252798818676107273127463057162208073142618039409911wb,
+    25132435181738021677664552852329012363786311024121402747618663944355967806315928846073722774898wb,
+    -24501129715197464074815490290653wb,
+    -26621511339033230503491791253914731850253401wb,
+    219726795681725191949095808767196099036895435893837474958165415185577738548053399820419849wb,
+    142706206515281341916417852232439287400819155237127620529348000437671770471697052705666056232742428920527wb,
+    -1272097813202031618710288063584910456400985264371503722255927680393419899507092728461wb,
+    104580584066897755717617980935051171929519336855902844943415231226523598033953128466889325153396268078513996620240379420239887wb,
+    -10163452549280413821027501723364683075067110986059205073343287754152825761658667193285948456506970145368258900765489010580419998927374372004822965287098902519382wb,
+    -1462817702603947401421838547412731208810505797188084686210372939517152226213737422286025118826482655559744680456146694118022879735528111700409wb,
+    -1004473459167555639043426932334304398038355185104669wb,
+    383945882095471823332216311173956104021530654187057868803605149628498470119801535759629951357637987556377174553957515312582545289930138018wb,
+    147266903774875157001493887893421901156259749590403482558013070wb
+  };
+  static unsigned _BitInt(575) u_575[] = {
+    340315902121482071031uwb,
+    9193736781349493374149172723522049938732355975055uwb,
+    121133456126887617775249483436586396232697894267611535022240817951287068117843073672uwb,
+    1253811282917666038992497uwb,
+    279807426767721176279253888473522991149118862415710500804613956730247764438409575562386uwb,
+    4763192686302836059965684032432862167583119264783uwb,
+    19433750446582365356875213925336734177599085624532213292961813424848222698351037862663241858724337375675uwb,
+    8615689860907972907203187028321798323548254692780962654211537619771698680316938530412569744897459065621193843349775333790731199245018643579445580816793381624810616262uwb,
+    126055589776274659515356020606486923511478187977197128509709117843059226901071386846700207970626608150351060714322162254429913496135590117225450775153364768928781244uwb,
+    34636325529158225079379169125604752070369970834816893592982969115088710130160324580864333959889906313467177163564702338046445540uwb,
+    2295982750677874548137685137480985649627965059590627454944uwb,
+    22288650253829612832302454550260146151077393473uwb,
+    61551827uwb,
+    948415991495935226718622697967024251064408554619458611515264819726244946850447758605031396753280209023664964305741301009407513619686102uwb,
+    7599947921908039117808602805272900633862767543347735124983729771592896283177667324402886239291446uwb,
+    3064098671438076295010586583414642866550259610904044948559784636731818131096680869327433283805326015689481397549653557650965154282598345191654721039973597171695049076467uwb,
+    26163216482276433755253744705785501134309546797499410671258175352214852627310317854549342428286751107453875459uwb,
+    1083530146709801198539441549736949256980046185455966999062614188586191607484611079705240990524552846829821534154580456458426794497253838343299379036578711641930103uwb,
+    241446995995054305582384233456322509709013171336859127uwb,
+    224319712854uwb,
+    1851847735563213275uwb,
+    3517907813008404838784133683859253992uwb,
+    57026061017409510123542169719303829618100077009666501089739966522905673377916488253uwb,
+    218054639772618074096850378810323560503313926757275788155487065187235936858569852576120793613879980uwb,
+    1035184782769221379uwb,
+    20229959242348674822834301353257599618846169820699281424077697412860273533283192155424030349307384555863768665398854990uwb,
+    48688062002166777196074419660880812175599377353811333642743225865182422320253615211852611218169059717666168172585704763331192485699241038689921302806665184uwb,
+    38974159722814402881994907079236516884965127718714589284306855526034875317101125387287977578141556918226042568695412232uwb,
+    195268331869690963115384309853070889302314974440838447729079592004150231uwb,
+    131384791058457562831689753115846222538215620945564207628285200123621656731679644407994773520965uwb,
+    1334982489788592107403503927792629194402uwb,
+    2146uwb,
+    25165296015221802429838428736907886uwb,
+    6254uwb
+  };
+#endif
+#if __FLT_MANT_DIG__ == 24
+#if __BITINT_MAXWIDTH__ >= 135
+  static float flt_135[] = {
+    -39242092.0f,
+    -36246971272809749294350336.0f,
+    -816440672256.0f,
+    8409360.0f,
+    231875.0f,
+    -1859.0f,
+    8123250192256220137057345512566423552.0f,
+    42642092.0f,
+    -2499664867657543876622680064.0f,
+    -14022533900570342719488.0f,
+    737816710112426075969552384.0f,
+    3094418676109759732222008215207936.0f,
+    84096.0f,
+    -3856393689890816.0f,
+    5494.0f,
+    -7227655905181068951552.0f,
+    185250718389633024.0f,
+    -266695840144413128032863408636297216.0f,
+    124.0f,
+    -4540724759502527537506259606437888.0f,
+    -34474124.0f,
+    6171186.0f,
+    -1738448585705717460364844982721314816.0f,
+    3714.0f,
+    22759309744814802127092016612376576.0f,
+    -461.0f,
+    -__builtin_inff (),
+    -350.0f,
+    3721759435945004998144961806336.0f,
+    -42485872567125016576.0f,
+    4362279465016690611605542535168.0f,
+    __builtin_inff (),
+    -50129.0f,
+    -21525556388157878481977344.0f
+  };
+  static float fltu_135[] = {
+    __builtin_inff (),
+    897485251387475481828390233702400.0f,
+    37306898327013391597568.0f,
+    3.0f,
+    920156.0f,
+    15230974228367008360756701604872192.0f,
+    1383843467413878101508096.0f,
+    143810078160377684059996776503967744.0f,
+    83615893330389964423168.0f,
+    1239150336.0f,
+    39792041984.0f,
+    20985036144640.0f,
+    3700707.0f,
+    14510535475200.0f,
+    5675982933774352481468669797335040.0f,
+    593909606786098794594304.0f,
+    413008901830615236608.0f,
+    34694483968.0f,
+    592129.0f,
+    2649.0f,
+    154468455934475733304034734374912.0f,
+    __builtin_inff (),
+    456.0f,
+    12101.0f,
+    5879086080.0f,
+    115170059747328.0f,
+    __builtin_inff (),
+    63923151928943443968.0f,
+    __builtin_inff (),
+    9.0f,
+    5703520697688581472256.0f,
+    44653117440.0f,
+    1440439672101666816.0f,
+    3496654143488.0f
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testflt_135 (s_135[i]) != flt_135[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testfltu_135 (u_135[i]) != fltu_135[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static float flt_192[] = {
+    81945579470551984745273979116049137664.0f,
+    1640150781354328003699743106531328.0f,
+    432402474830816591643797717254144.0f,
+    -__builtin_inff (),
+    217705802104832.0f,
+    1.0f,
+    -150837356860384332849610752.0f,
+    1247354020200583118196884635648.0f,
+    -700073528334631668550369017856.0f,
+    -__builtin_inff (),
+    -743993169284474461872900775245512704.0f,
+    1681039.0f,
+    -__builtin_inff (),
+    -97703169989152795899105082605568.0f,
+    9.0f,
+    7277656062827612295463998324736.0f,
+    7201222144.0f,
+    -4671533860148685993668956641034240.0f,
+    13311155535609252557094912.0f,
+    __builtin_inff (),
+    -283560864177100653079149659746813870080.0f,
+    __builtin_inff (),
+    1122038754191063555360632711675904.0f,
+    -9541613258608657772880016179200.0f,
+    21551010941830070997495077018796032.0f,
+    -4794294027361853497357107200.0f,
+    -5708612694366486528.0f,
+    -__builtin_inff (),
+    -35698660648279573790720.0f,
+    -79587925032960.0f,
+    469393711604695040.0f,
+    -__builtin_inff (),
+    -115.0f,
+    -1717706686464.0f
+  };
+  static float fltu_192[] = {
+    __builtin_inff (),
+    __builtin_inff (),
+    289472678477035675109665275904.0f,
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    512829259776.0f,
+    __builtin_inff (),
+    1918805247503610004149880487936.0f,
+    99680641842413568.0f,
+    313647265860414511058971000832.0f,
+    __builtin_inff (),
+    1751643624308736.0f,
+    24084145747217780385007409962156032.0f,
+    1282076.0f,
+    13590701491613597696.0f,
+    62207548751752462336.0f,
+    144040024354059546360660309323802476544.0f,
+    __builtin_inff (),
+    __builtin_inff (),
+    4649.0f,
+    __builtin_inff (),
+    __builtin_inff (),
+    11488350322032640.0f,
+    __builtin_inff (),
+    36826148503552.0f,
+    554404238373758103887118598144.0f,
+    2804528971776.0f,
+    127.0f,
+    66823887263746144234653953818624.0f,
+    297736634368.0f,
+    __builtin_inff (),
+    107247050752.0f
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testflt_192 (s_192[i]) != flt_192[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testfltu_192 (u_192[i]) != fltu_192[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static float flt_575[] = {
+    __builtin_inff (),
+    -__builtin_inff (),
+    __builtin_inff (),
+    275983721032549254738830597716881440768.0f,
+    __builtin_inff (),
+    __builtin_inff (),
+    -__builtin_inff (),
+    -__builtin_inff (),
+    __builtin_inff (),
+    -3523803575380752640275405340672.0f,
+    -__builtin_inff (),
+    -__builtin_inff (),
+    8137926508544.0f,
+    -15994393281493713095582868026949632.0f,
+    -__builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    2003391250601164668928.0f,
+    -__builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    -24501130336514943435685610127360.0f,
+    -__builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    -__builtin_inff (),
+    __builtin_inff (),
+    -__builtin_inff (),
+    -__builtin_inff (),
+    -__builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff ()
+  };
+  static float fltu_575[] = {
+    340315913217135083520.0f,
+    __builtin_inff (),
+    __builtin_inff (),
+    1253811215516794865319936.0f,
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    61551828.0f,
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    224319717376.0f,
+    1851847786157309952.0f,
+    3517907886717368541269560933367152640.0f,
+    __builtin_inff (),
+    __builtin_inff (),
+    1035184768712441856.0f,
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    __builtin_inff (),
+    2146.0f,
+    25165295728767510106569460506689536.0f,
+    6254.0f
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testflt_575 (s_575[i]) != flt_575[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testfltu_575 (u_575[i]) != fltu_575[i])
+      __builtin_abort ();
+#endif
+#endif
+#if __DBL_MANT_DIG__ == 53
+#if __BITINT_MAXWIDTH__ >= 135
+  static double dbl_135[] = {
+    -39242093.0,
+    -36246971635108657531715584.0,
+    -816440703352.0,
+    8409360.0,
+    231875.0,
+    -1859.0,
+    8123250453541346905042562585110511616.0,
+    42642091.0,
+    -2499664813007708750469922816.0,
+    -14022533493907733348352.0,
+    737816709430180073007218688.0,
+    3094418595787172340280288631324672.0,
+    84096.0,
+    -3856393637064417.0,
+    5494.0,
+    -7227655824382622695424.0,
+    185250722103742944.0,
+    -266695839223233236177082217685581824.0,
+    124.0,
+    -4540724906728462124105811223379968.0,
+    -34474123.0,
+    6171186.0,
+    -1738448518309495524665904679484391424.0,
+    3714.0,
+    22759310366655439518928576500989952.0,
+    -461.0,
+    -1891475049610273567723258005078180626432.0,
+    -350.0,
+    3721759411106519834940439265280.0,
+    -42485872965031411712.0,
+    4362279409022137156015669379072.0,
+    521928664204421058633672118513103273984.0,
+    -50129.0,
+    -21525556783117337240797184.0
+  };
+  static double dblu_135[] = {
+    773802493804221992623001034499154771968.0,
+    897485218654369723848104601452544.0,
+    37306898634990774386688.0,
+    3.0,
+    920156.0,
+    15230973698181137968871516305096704.0,
+    1383843491123931258028032.0,
+    143810081711544982658521010624528384.0,
+    83615891310230336700416.0,
+    1239150390.0,
+    39792042288.0,
+    20985035121604.0,
+    3700707.0,
+    14510535740825.0,
+    5675982879048652786568565738176512.0,
+    593909622129190116524032.0,
+    413008891327830556672.0,
+    34694483328.0,
+    592129.0,
+    2649.0,
+    154468451808267468485637384962048.0,
+    8905088171048376547587929854079236308992.0,
+    456.0,
+    12101.0,
+    5879086272.0,
+    115170058487623.0,
+    2274163249406113722963963066981556420608.0,
+    63923152267905662976.0,
+    624302860090054299856857502421553774592.0,
+    9.0,
+    5703520721951508135936.0,
+    44653119094.0,
+    1440439605268989184.0,
+    3496654014361.0
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testdbl_135 (s_135[i]) != dbl_135[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testdblu_135 (u_135[i]) != dblu_135[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static double dbl_192[] = {
+    81945579384314687557742233571238608896.0,
+    1640150770700583037463354142621696.0,
+    432402469012491501348574281596928.0,
+    -15369197386440508938509968376382119346509732380672.0,
+    217705797486262.0,
+    1.0,
+    -150837356854711041828847616.0,
+    1247354027519369502575283929088.0,
+    -700073531555662276303601532928.0,
+    -441651351073606679519160525300938309632.0,
+    -743993151249791396098631688421113856.0,
+    1681039.0,
+    -170386616439159361826828161968707433660416.0,
+    -97703172400304826279491553722368.0,
+    9.0,
+    7277656199366069333121407385600.0,
+    7201222364.0,
+    -4671533967546296379435628906938368.0,
+    13311155734490577941561344.0,
+    76150533189365686624757419076841278552408064.0,
+    -283560863483321472582205283908875976704.0,
+    6438368552004797730833578371043525700779108699471872.0,
+    1122038765213390753205991088586752.0,
+    -9541613313421359725756721135616.0,
+    21551012076757076520029583197601792.0,
+    -4794294047755173506637103104.0,
+    -5708612827808553984.0,
+    -2649648007071280532341234166535418312753414144.0,
+    -35698660478241256505344.0,
+    -79587921140918.0,
+    469393710173925632.0,
+    -261330983098092727670915068943820759127419298070396928.0,
+    -115.0,
+    -1717706681396.0
+  };
+  static double dblu_192[] = {
+    87197051833867272390202829166908318800909697024.0,
+    175207476610687217879860344599290566299997853188096.0,
+    289472685412214309690412105728.0,
+    58352315342320052737011578650960945217536.0,
+    68512267071922037583525562378571212344840731754496.0,
+    8654067584750856522039960763727020807946240.0,
+    57027948061283101680073163019018106591772672.0,
+    512829256101.0,
+    8815296701808550079625439512864915193856.0,
+    1918805208198312244509799350272.0,
+    99680639255733808.0,
+    313647272226958910616850399232.0,
+    534434342549592748637063994840786615140352.0,
+    1751643652514709.0,
+    24084146046683127568067882664329216.0,
+    1282076.0,
+    13590701668411111424.0,
+    62207549230439505920.0,
+    144040025133692463994664792383004082176.0,
+    11981724905403944877595374666928320404518862848.0,
+    1823479497818478827998416063488921051624645800235106304.0,
+    4649.0,
+    2095541338428713553559812835366404384524126144954368.0,
+    605377488765896315082607405999750595789425999872.0,
+    11488350477184224.0,
+    9492972359709013522794710883315474336917948771336192.0,
+    36826148417259.0,
+    554404239122129838954063593472.0,
+    2804528919100.0,
+    127.0,
+    66823885107232869968562331058176.0,
+    297736625249.0,
+    3701132312864550589964164920177814261972243111315767296.0,
+    107247048428.0
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testdbl_192 (s_192[i]) != dbl_192[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testdblu_192 (u_192[i]) != dblu_192[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static double dbl_575[] = {
+    822555268170764297634225399451759946746992540590809881338557024729825280.0,
+    -960580267694575822855611495941585347204287976360447994911667455476231250947192048882720653908949004193890304.0,
+    33504080263976494977558165276907141142985667083206076858318677497395449849522674033540660299812700936436629271063580537369602818048.0,
+    275983725374553560382241222733294731264.0,
+    5534912144897227981721785252365318913099024300479520929615780375858014135428545244514013933284386952701873840884059278413011909801315647098618874845818373456314285330268160.0,
+    1412920302762670981724654587829101441064363178039081649317449002875219686863615617096481906597938056255380563207859934619548778496.0,
+    -262974997977953547412616819382246513411941636601411079958856272578116216992825344.0,
+    -92488905333378800887332041285981414442679115849793894833270926171369794209000194048.0,
+    242604167696163745705487164545064266366976.0,
+    -3523803651131338905043794395136.0,
+    -5147220779398204956062097693667869669268514878983078506579452381903246893001528080183706343394366450560829994902536411900094807055106480897434592050304516096.0,
+    -126995956651641932664992814931771424612524306428042763656077526441611704177400372487041993300114407424.0,
+    8137926360495.0,
+    -15994393111836745817684083180830720.0,
+    -277068516868681208843378539444762089120272250101874770818281861285776026097252118136221894703961747524419584.0,
+    12643256666940490094502018407000917191440297183002304612995222607645672663994449919572180992.0,
+    197250790460297249337611855831853736085011038208.0,
+    2003391279347377111040.0,
+    -199877387236416487880239440186867935179678108631030562816.0,
+    683783725793437376953847532054635915450883103104150353591684114076623183460343349044869993313461680324691804857056989176851941526653681669242880.0,
+    13527430925075103137395594360375039920265895975276069404569617039360.0,
+    539267000300803467143224409095377978528526384444410994726548852694612047977432378724606879533366903144710144.0,
+    25132435181738021158181758368227989609664280796006529821958155232496895580737809559413590065152.0,
+    -24501129715197465145324272091136.0,
+    -26621511339033229577933593130365525581365248.0,
+    219726795681725203086615878008721704050996541338139327356409273606611142342004775592132608.0,
+    142706206515281338563561427905630882997359612390115520631287147248801675296196390219660900162069776564224.0,
+    -1272097813202031695774673850580967606153271008283204619545732236750677292631566843904.0,
+    104580584066897764106493049954563517551311873970918028573957449051117037877644455167894862496406485527470814840408584063287296.0,
+    -10163452549280414266636885849517652803498703924514090324303688401722691539656540095676077155202913299163727204412770763270991539282383353646632785170429061890048.0,
+    -1462817702603947424514705987528105462111189926351038186632282100495484739291866737828490405005509893174352599206536639203945990323918788886528.0,
+    -1004473459167555693379448563952458083163231922159616.0,
+    383945882095471809778477642717090299126500715170441296829413124731981221073489411436597060515704853514279862909459893170581511755452645376.0,
+    147266903774875160122803299680751368800498930915627484017852416.0
+  };
+  static double dblu_575[] = {
+    340315902121482059776.0,
+    9193736781349493621405581031201638729956693377024.0,
+    121133456126887614949840563267333164930922114527830924098169755757644187539060293632.0,
+    1253811282917665907146752.0,
+    279807426767721167224232624903862775521562023356169096523467570552357504424852523581440.0,
+    4763192686302836266016084152796744123294035214336.0,
+    19433750446582363914783523863519537892469170046699527182095230312993931481088146791402683275534315552768.0,
+    8615689860907973684813089916677872622369301590036773127424335682014143120538819857749267776316706246365207593078790418785926108454964638864284607647395585351338688512.0,
+    126055589776274664055563357164473926765229686711256362550309370211691455811892471436667901827515295553040869973224666092493870267949222939304809964524921924217733120.0,
+    34636325529158225609732004478359404024810355780116436151965488784911880463832346975056353708910319963631363476007842111096356864.0,
+    2295982750677874440830690242430022722310395038479306194944.0,
+    22288650253829611656582899585105561922738061312.0,
+    61551827.0,
+    948415991495935277158065207187216102893971687538169358437498088171511819979329197955070708594226287655578579327935243978625908341735424.0,
+    7599947921908039201020389523460283262016591366306988284476594385856376859892071911998135440769024.0,
+    3064098671438076262631558926659124050612030123593391586289496610357367704588066201089697403929948683093930760302363801622713089626566308942422673109893593769913375260672.0,
+    26163216482276434323059552752807045466093212833119225389172469300377369630622147477953596829696868035573317632.0,
+    1083530146709801287488575139896111218252634145778954464029109940268038137024528653987999105697728348938546608345738475665376063185384327227976954513446733080428544.0,
+    241446995995054294694559180878245213888164982782164992.0,
+    224319712854.0,
+    1851847735563213312.0,
+    3517907813008404560136740290886107136.0,
+    57026061017409511227244639666735331364603008817984523485318163959373956415485902848.0,
+    218054639772618086702097627512642011917064593803091900409463425864524464099706282773581011770933248.0,
+    1035184782769221376.0,
+    20229959242348673341261734187831508959698424427160892456742004821954487315365414763816110107652513076773401171962363904.0,
+    48688062002166779121886848500298978377358186775166569744218208875095511886249915901603271262547063601222998163903380246886122115788425950691666910366400512.0,
+    38974159722814403783188765470424741900583576369459629735378952745201038923704525454001059605107694314700748523810324480.0,
+    195268331869690962780067959053006275481517082721312675880802634445094912.0,
+    131384791058457555617616111281677184113372650274571562034279153020161645779289769480396688326656.0,
+    1334982489788592098527293353260669206528.0,
+    2146.0,
+    25165296015221801457062319885385728.0,
+    6254.0
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testdbl_575 (s_575[i]) != dbl_575[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testdblu_575 (u_575[i]) != dblu_575[i])
+      __builtin_abort ();
+#endif
+#endif
+}
--- gcc/testsuite/gcc.dg/torture/bitint-24.c.jj	2023-07-27 15:03:24.246234285 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-24.c	2023-07-27 15:03:24.246234285 +0200
@@ -0,0 +1,804 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __LDBL_MANT_DIG__ == 64
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) long double
+testldbl_135 (_BitInt(135) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) long double
+testldblu_135 (unsigned _BitInt(135) b)
+{
+  return b;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) long double
+testldbl_192 (_BitInt(192) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) long double
+testldblu_192 (unsigned _BitInt(192) b)
+{
+  return b;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) long double
+testldbl_575 (_BitInt(575) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) long double
+testldblu_575 (unsigned _BitInt(575) b)
+{
+  return b;
+}
+#endif
+#endif
+
+#if __FLT128_MANT_DIG__ == 113
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) _Float128
+testflt128_135 (_BitInt(135) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) _Float128
+testflt128u_135 (unsigned _BitInt(135) b)
+{
+  return b;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) _Float128
+testflt128_192 (_BitInt(192) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) _Float128
+testflt128u_192 (unsigned _BitInt(192) b)
+{
+  return b;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) _Float128
+testflt128_575 (_BitInt(575) b)
+{
+  return b;
+}
+
+__attribute__((noipa)) _Float128
+testflt128u_575 (unsigned _BitInt(575) b)
+{
+  return b;
+}
+#endif
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 135
+  static _BitInt(135) s_135[] = {
+    -39242093wb,
+    -36246971635108657318127321wb,
+    -816440703352wb,
+    8409360wb,
+    231875wb,
+    -1859wb,
+    8123250453541347379290840008816194983wb,
+    42642091wb,
+    -2499664813007708583619356686wb,
+    -14022533493907734339644wb,
+    737816709430180009697449492wb,
+    3094418595787172583521548578719419wb,
+    84096wb,
+    -3856393637064417wb,
+    5494wb,
+    -7227655824382622730861wb,
+    185250722103742953wb,
+    -266695839223233222300219080587185431wb,
+    124wb,
+    -4540724906728461994579131745203067wb,
+    -34474123wb,
+    6171186wb,
+    -1738448518309495501564259945530043942wb,
+    3714wb,
+    22759310366655438105064084505115489wb,
+    -461wb,
+    -1891475049610273521994429918325638525836wb,
+    -350wb,
+    3721759411106519959861226774340wb,
+    -42485872965031409753wb,
+    4362279409022137273490486629950wb,
+    521928664204421037572709995195346211111wb,
+    -50129wb,
+    -21525556783117336078661729wb
+  };
+  static unsigned _BitInt(135) u_135[] = {
+    773802493804221964748670742461281016363uwb,
+    897485218654369665002411485681173uwb,
+    37306898634990773758633uwb,
+    3uwb,
+    920156uwb,
+    15230973698181139105641901258312096uwb,
+    1383843491123931387484696uwb,
+    143810081711544975903357370071668200uwb,
+    83615891310230331473978uwb,
+    1239150390uwb,
+    39792042288uwb,
+    20985035121604uwb,
+    3700707uwb,
+    14510535740825uwb,
+    5675982879048653163399531637816917uwb,
+    593909622129190124122830uwb,
+    413008891327830587264uwb,
+    34694483328uwb,
+    592129uwb,
+    2649uwb,
+    154468451808267466822214091328849uwb,
+    8905088171048376399858691570634230197204uwb,
+    456uwb,
+    12101uwb,
+    5879086272uwb,
+    115170058487623uwb,
+    2274163249406113742515726136586945854500uwb,
+    63923152267905666653uwb,
+    624302860090054295150365837280525227924uwb,
+    9uwb,
+    5703520721951508439418uwb,
+    44653119094uwb,
+    1440439605268989101uwb,
+    3496654014361uwb
+  };
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static _BitInt(192) s_192[] = {
+    81945579384314684613279565479277935940wb,
+    1640150770700583136800158704601080wb,
+    432402469012491481987292073086668wb,
+    -15369197386440508323548800500962985157137866798390wb,
+    217705797486262wb,
+    1wb,
+    -150837356854711044278780637wb,
+    1247354027519369533750440146304wb,
+    -700073531555662209687924602081wb,
+    -441651351073606706893667405889558445894wb,
+    -743993151249791392844844248857961054wb,
+    1681039wb,
+    -170386616439159353410812029301398243129730wb,
+    -97703172400304820221345002831889wb,
+    9wb,
+    7277656199366069102639319241893wb,
+    7201222364wb,
+    -4671533967546296507223686237333335wb,
+    13311155734490577635922550wb,
+    76150533189365685907637983428512213977569647wb,
+    -283560863483321465221194695455688610811wb,
+    6438368552004797088499844257634549000496626110080371wb,
+    1122038765213390728664343086041576wb,
+    -9541613313421359977755878156940wb,
+    21551012076757076795102244535269250wb,
+    -4794294047755173531367558272wb,
+    -5708612827808554221wb,
+    -2649648007071280662902443553973167294046518180wb,
+    -35698660478241255546377wb,
+    -79587921140918wb,
+    469393710173925646wb,
+    -261330983098092746969723637867599382044980841179747207wb,
+    -115wb,
+    -1717706681396wb
+  };
+  static unsigned _BitInt(192) u_192[] = {
+    87197051833867272589618945858714291675632402028uwb,
+    175207476610687227705633653396153452205075322355946uwb,
+    289472685412214318981767004188uwb,
+    58352315342320048378103056601781218026976uwb,
+    68512267071922032916894194298300228491490143452269uwb,
+    8654067584750856592691725728280108682858075uwb,
+    57027948061283099317671673937496946487124629uwb,
+    512829256101uwb,
+    8815296701808550493421309771596155666520uwb,
+    1918805208198312310092547265227uwb,
+    99680639255733807uwb,
+    313647272226958893709907781719uwb,
+    534434342549592762863366619879590694414818uwb,
+    1751643652514709uwb,
+    24084146046683127013882581681582087uwb,
+    1282076uwb,
+    13590701668411111769uwb,
+    62207549230439503653uwb,
+    144040025133692457990548614076288499046uwb,
+    11981724905403945793356785358565398049196880116uwb,
+    1823479497818478859136796209626920064416489979129893695uwb,
+    4649uwb,
+    2095541338428713427585867932062430293488017906261402uwb,
+    605377488765896342050766363050545164888333863362uwb,
+    11488350477184223uwb,
+    9492972359709013710789022084605392630683565515935199uwb,
+    36826148417259uwb,
+    554404239122129842026250702689uwb,
+    2804528919100uwb,
+    127uwb,
+    66823885107232870336040073990324uwb,
+    297736625249uwb,
+    3701132312864550550157874952341371502832960625370598966uwb,
+    107247048428uwb
+  };
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static _BitInt(575) s_575[] = {
+    822555268170764275096048134868384963633463468104839796862654006268369616wb,
+    -960580267694575830808697063169243963045681635800151938720065734940592300657700227419337766780029829446319203wb,
+    33504080263976494448954627475165765154890874061543914469206217657999706310163279811015042121096338719830090426757797138233202615461wb,
+    275983725374553564148936957707321552749wb,
+    5534912144897227754137156977371639235252437172582938580045103986268272085395760563838753817115093434280932847973705994570261258933419373885658991359441723005813683395590541wb,
+    1412920302762671055711845665320769771488824036206881359103417821581950493952853265134760513685359011001836948515905971331797139790wb,
+    -262974997977953570994865210107604152900839198803859287819970850481583440338320059wb,
+    -92488905333378799268618025132022462336176863903734682501838771365453998891689279398wb,
+    242604167696163732697906496386839396751068wb,
+    -3523803651131338645439245946293wb,
+    -5147220779398204849222374563179412010462379234108857688330486391319694172748210918710342389194957287070617133280194810193962683650761347126311504766504260691wb,
+    -126995956651641937332005246092202755154992252553028943468563459072746155379181900761169956344678911600wb,
+    8137926360495wb,
+    -15994393111836746332671329788635258wb,
+    -277068516868681202554828866807401284583187899477211188256772654837767448404666578906477389363058609157862574wb,
+    12643256666940489874033990964997310860090310878838229112053311027168830831623703103010815387wb,
+    197250790460297242975596746662998763328365874997wb,
+    2003391279347376998472wb,
+    -199877387236416475658211887841938073691092213166438343739wb,
+    683783725793437346966376731991835336458591392078548990419792641719902684445391913394174240265031277360362886303597899811253111402611797905136669wb,
+    13527430925075101894748577029275389339063875642859674079897983403256wb,
+    539267000300803493510458136103246878203019746178696339759252798818676107273127463057162208073142618039409911wb,
+    25132435181738021677664552852329012363786311024121402747618663944355967806315928846073722774898wb,
+    -24501129715197464074815490290653wb,
+    -26621511339033230503491791253914731850253401wb,
+    219726795681725191949095808767196099036895435893837474958165415185577738548053399820419849wb,
+    142706206515281341916417852232439287400819155237127620529348000437671770471697052705666056232742428920527wb,
+    -1272097813202031618710288063584910456400985264371503722255927680393419899507092728461wb,
+    104580584066897755717617980935051171929519336855902844943415231226523598033953128466889325153396268078513996620240379420239887wb,
+    -10163452549280413821027501723364683075067110986059205073343287754152825761658667193285948456506970145368258900765489010580419998927374372004822965287098902519382wb,
+    -1462817702603947401421838547412731208810505797188084686210372939517152226213737422286025118826482655559744680456146694118022879735528111700409wb,
+    -1004473459167555639043426932334304398038355185104669wb,
+    383945882095471823332216311173956104021530654187057868803605149628498470119801535759629951357637987556377174553957515312582545289930138018wb,
+    147266903774875157001493887893421901156259749590403482558013070wb
+  };
+  static unsigned _BitInt(575) u_575[] = {
+    340315902121482071031uwb,
+    9193736781349493374149172723522049938732355975055uwb,
+    121133456126887617775249483436586396232697894267611535022240817951287068117843073672uwb,
+    1253811282917666038992497uwb,
+    279807426767721176279253888473522991149118862415710500804613956730247764438409575562386uwb,
+    4763192686302836059965684032432862167583119264783uwb,
+    19433750446582365356875213925336734177599085624532213292961813424848222698351037862663241858724337375675uwb,
+    8615689860907972907203187028321798323548254692780962654211537619771698680316938530412569744897459065621193843349775333790731199245018643579445580816793381624810616262uwb,
+    126055589776274659515356020606486923511478187977197128509709117843059226901071386846700207970626608150351060714322162254429913496135590117225450775153364768928781244uwb,
+    34636325529158225079379169125604752070369970834816893592982969115088710130160324580864333959889906313467177163564702338046445540uwb,
+    2295982750677874548137685137480985649627965059590627454944uwb,
+    22288650253829612832302454550260146151077393473uwb,
+    61551827uwb,
+    948415991495935226718622697967024251064408554619458611515264819726244946850447758605031396753280209023664964305741301009407513619686102uwb,
+    7599947921908039117808602805272900633862767543347735124983729771592896283177667324402886239291446uwb,
+    3064098671438076295010586583414642866550259610904044948559784636731818131096680869327433283805326015689481397549653557650965154282598345191654721039973597171695049076467uwb,
+    26163216482276433755253744705785501134309546797499410671258175352214852627310317854549342428286751107453875459uwb,
+    1083530146709801198539441549736949256980046185455966999062614188586191607484611079705240990524552846829821534154580456458426794497253838343299379036578711641930103uwb,
+    241446995995054305582384233456322509709013171336859127uwb,
+    224319712854uwb,
+    1851847735563213275uwb,
+    3517907813008404838784133683859253992uwb,
+    57026061017409510123542169719303829618100077009666501089739966522905673377916488253uwb,
+    218054639772618074096850378810323560503313926757275788155487065187235936858569852576120793613879980uwb,
+    1035184782769221379uwb,
+    20229959242348674822834301353257599618846169820699281424077697412860273533283192155424030349307384555863768665398854990uwb,
+    48688062002166777196074419660880812175599377353811333642743225865182422320253615211852611218169059717666168172585704763331192485699241038689921302806665184uwb,
+    38974159722814402881994907079236516884965127718714589284306855526034875317101125387287977578141556918226042568695412232uwb,
+    195268331869690963115384309853070889302314974440838447729079592004150231uwb,
+    131384791058457562831689753115846222538215620945564207628285200123621656731679644407994773520965uwb,
+    1334982489788592107403503927792629194402uwb,
+    2146uwb,
+    25165296015221802429838428736907886uwb,
+    6254uwb
+  };
+#endif
+#if __LDBL_MANT_DIG__ == 64
+#if __BITINT_MAXWIDTH__ >= 135
+  static long double ldbl_135[] = {
+    -39242093.0L,
+    -36246971635108657317806080.0L,
+    -816440703352.0L,
+    8409360.0L,
+    231875.0L,
+    -1859.0L,
+    8123250453541347379469761730828042240.0L,
+    42642091.0L,
+    -2499664813007708583503069184.0L,
+    -14022533493907734339584.0L,
+    737816709430180009723559936.0L,
+    3094418595787172583474668509331456.0L,
+    84096.0L,
+    -3856393637064417.0L,
+    5494.0L,
+    -7227655824382622730752.0L,
+    185250722103742953.0L,
+    -266695839223233222305995365384454144.0L,
+    124.0L,
+    -4540724906728461994627321936478208.0L,
+    -34474123.0L,
+    6171186.0L,
+    -1738448518309495501607474587347451904.0L,
+    3714.0L,
+    22759310366655438104798293506654208.0L,
+    -461.0L,
+    -1891475049610273521975332702278492618752.0L,
+    -350.0L,
+    3721759411106519959735009017856.0L,
+    -42485872965031409752.0L,
+    4362279409022137273388535644160.0L,
+    521928664204421037567490386336795328512.0L,
+    -50129.0L,
+    -21525556783117336078974976.0L
+  };
+  static long double ldblu_135[] = {
+    773802493804221964731523995050312728576.0L,
+    897485218654369665019834468925440.0L,
+    37306898634990773757952.0L,
+    3.0L,
+    920156.0L,
+    15230973698181139106030422216146944.0L,
+    1383843491123931387527168.0L,
+    143810081711544975903121569568784384.0L,
+    83615891310230331473920.0L,
+    1239150390.0L,
+    39792042288.0L,
+    20985035121604.0L,
+    3700707.0L,
+    14510535740825.0L,
+    5675982879048653163182084577034240.0L,
+    593909622129190124126208.0L,
+    413008891327830587264.0L,
+    34694483328.0L,
+    592129.0L,
+    2649.0L,
+    154468451808267466823175803764736.0L,
+    8905088171048376400013977264402823380992.0L,
+    456.0L,
+    12101.0L,
+    5879086272.0L,
+    115170058487623.0L,
+    2274163249406113742443724808818842927104.0L,
+    63923152267905666652.0L,
+    624302860090054295134491019551908560896.0L,
+    9.0L,
+    5703520721951508439552.0L,
+    44653119094.0L,
+    1440439605268989101.0L,
+    3496654014361.0L
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testldbl_135 (s_135[i]) != ldbl_135[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testldblu_135 (u_135[i]) != ldblu_135[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static long double ldbl_192[] = {
+    81945579384314684615486553814565126144.0L,
+    1640150770700583136824020921483264.0L,
+    432402469012491481997169632739328.0L,
+    -15369197386440508323699427265690859620608677773312.0L,
+    217705797486262.0L,
+    1.0L,
+    -150837356854711044278321152.0L,
+    1247354027519369533773926367232.0L,
+    -700073531555662209714428575744.0L,
+    -441651351073606706894128730685912907776.0L,
+    -743993151249791392856039956714356736.0L,
+    1681039.0L,
+    -170386616439159353411571089494999662854144.0L,
+    -97703172400304820218983461421056.0L,
+    9.0L,
+    7277656199366069102773721366528.0L,
+    7201222364.0L,
+    -4671533967546296507225268333576192.0L,
+    13311155734490577636425728.0L,
+    76150533189365685909073333864980807126351872.0L,
+    -283560863483321465221954398498764881920.0L,
+    6438368552004797088286842127358606670130187958484992.0L,
+    1122038765213390728647299370582016.0L,
+    -9541613313421359977544883896320.0L,
+    21551012076757076794749160467202048.0L,
+    -4794294047755173531333165056.0L,
+    -5708612827808554221.0L,
+    -2649648007071280662943908311143037314611019776.0L,
+    -35698660478241255546880.0L,
+    -79587921140918.0L,
+    469393710173925646.0L,
+    -261330983098092746965490195259240226746743657452273664.0L,
+    -115.0L,
+    -1717706681396.0L
+  };
+  static long double ldblu_192[] = {
+    87197051833867272588273235452569162784769572864.0L,
+    175207476610687227706687797568524886702441101262848.0L,
+    289472685412214318984721334272.0L,
+    58352315342320048378267314962278412976128.0L,
+    68512267071922032918571353538687014836972935970816.0L,
+    8654067584750856592762121211182827528257536.0L,
+    57027948061283099315414259852803440866492416.0L,
+    512829256101.0L,
+    8815296701808550493422802574317577043968.0L,
+    1918805208198312310068180156416.0L,
+    99680639255733807.0L,
+    313647272226958893711859122176.0L,
+    534434342549592762879721307175636579647488.0L,
+    1751643652514709.0L,
+    24084146046683127014125128497758208.0L,
+    1282076.0L,
+    13590701668411111769.0L,
+    62207549230439503652.0L,
+    144040025133692457990249596390545031168.0L,
+    11981724905403945793671003738109723829870788608.0L,
+    1823479497818478859069120464961329580751135834288160768.0L,
+    4649.0L,
+    2095541338428713427646614015896834392659590161367040.0L,
+    605377488765896342059796742106757546391141089280.0L,
+    11488350477184223.0L,
+    9492972359709013711015472005202975871148440705564672.0L,
+    36826148417259.0L,
+    554404239122129842012080308224.0L,
+    2804528919100.0L,
+    127.0L,
+    66823885107232870337998237990912.0L,
+    297736625249.0L,
+    3701132312864550550087325046630338074858031302905430016.0L,
+    107247048428.0L
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testldbl_192 (s_192[i]) != ldbl_192[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testldblu_192 (u_192[i]) != ldblu_192[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static long double ldbl_575[] = {
+    822555268170764275077806657331958312785072234722196584950240570089930752.0L,
+    -960580267694575830812783278498171621690403946709581436518965868233794729994615679173272606109483012722786304.0L,
+    33504080263976494448478492229617991564043478238504231331124912879329149376584163966764611121993710792934518914942887118335291424768.0L,
+    275983725374553564145377013770043260928.0L,
+    5534912144897227754208044441151874379702287612174069453950291607680839007181861996360330547973886690095069343864416739797783816199380471673982675880600014677768303758278656.0L,
+    1412920302762671055675563434211562120848328209741725967322941102900395775694793728702679689406728724040334624347456855689117302784.0L,
+    -262974997977953570989611804750151836163609455430948784164618597359252696534614016.0L,
+    -92488905333378799268155556881914668962189440213360997930258834387927208673968914432.0L,
+    242604167696163732690645137756322057420800.0L,
+    -3523803651131338645559050240000.0L,
+    -5147220779398204849257508190774210744388677252688140210517976277065981842998232251783846790859222005317012238819263034139406832143929230632126090335152504832.0L,
+    -126995956651641937331951286489675247329200371648605762035297081195775007184684091195737834711064510464.0L,
+    8137926360495.0L,
+    -15994393111836746332220340607909888.0L,
+    -277068516868681202557212831225058932276240633526059351948516115207300877649787450206685852465539880786591744.0L,
+    12643256666940489873646135309702875993528109590137490134559735498193302898793674757994708992.0L,
+    197250790460297242979551814062140644203109023744.0L,
+    2003391279347376998528.0L,
+    -199877387236416475651341878965641904464653154051860463616.0L,
+    683783725793437346957771892228315489408774085809131650337993219889398577200119614673432810174598052160906191944536223932553104679193775255322624.0L,
+    13527430925075101895119202629107559447133788166435502697026955509760.0L,
+    539267000300803493497377352922791719626542478240740953329921195747662290582499442246914945221535539392413696.0L,
+    25132435181738021677436908541817803462240416694341366601465742717478799945180412844899030794240.0L,
+    -24501129715197464074399946637312.0L,
+    -26621511339033230503970770955171473406296064.0L,
+    219726795681725191947197274288751751131300579623020247100319392523607242309690678380068864.0L,
+    142706206515281341912722598102787801262511939753862115682796537774690209934320984609531887855849227419648.0L,
+    -1272097813202031618686076349197106943277274743836448162114522403548727854475931287552.0L,
+    104580584066897755721462109894862071102150680746488173021715848651881249493019658369304827516906027223482984669789074019581952.0L,
+    -10163452549280413820781685181828332647679763634230328394877439998644536448688077844493834184118223902098524496370094218227350253632267534838755399334577766924288.0L,
+    -1462817702603947401460379075968185573663143558708148172616668782116177216739740002633588435639151707520878885121466080144202470951229168025600.0L,
+    -1004473459167555639022590826165981346984598475636736.0L,
+    383945882095471823335289502673360394820076368186253637060368537085404663434451033274997076104121125319917967630183508209073164612376985600.0L,
+    147266903774875157000698971886464128985498372744856873180594176.0L
+  };
+  static long double ldblu_575[] = {
+    340315902121482071040.0L,
+    9193736781349493374213713986696905438099568328704.0L,
+    121133456126887617773526383630522733268849231796244390648544501184867233045273378816.0L,
+    1253811282917666039005184.0L,
+    279807426767721176282774705066477746529679092594765002865548096525989858075665567318016.0L,
+    4763192686302836060022861615709466380079764340736.0L,
+    19433750446582365356243841895010508514709904909750555910761104889681456249932954817669662897799021199360.0L,
+    8615689860907972907222987015567999691990010815316564361117521521881809095333131098584672097178927461838400993199702306526955489286031755082939241644835174978131329024.0L,
+    126055589776274659510297467904389237873624120132406221380350474491493460160959938222126650105936552657875183912780356083785858555181180003532557375481178518259236864.0L,
+    34636325529158225078961380771473094521787740905726267965061232731631589683984587408777114033008811740835389841050115225879052288.0L,
+    2295982750677874548189777005986107945005083683202176909312.0L,
+    22288650253829612832625936906216823076906074112.0L,
+    61551827.0L,
+    948415991495935226723497275802282711176800359354343687935431821975740085005513640520546841077796705045317773075243223746142080749010944.0L,
+    7599947921908039117650085272592622557045482160051694630122205426595170751482611426300682100015104.0L,
+    3064098671438076294956291179633525016992278379765933214428836815032632500735568461039018643426109912566222922020667353487719095386222010158443081500511850171532585205760.0L,
+    26163216482276433754726515355485427397196865766902718455812787467581155703138962108081214195725927010405449728.0L,
+    1083530146709801198518741455890332623877113096673714750194062874316360337538555304664904549334408175509822671036217297610308526225295574707709647653730601851158528.0L,
+    241446995995054305577613396367243923288085288827486208.0L,
+    224319712854.0L,
+    1851847735563213275.0L,
+    3517907813008404838855514029591363584.0L,
+    57026061017409510124756586261527283120773656504559685146885133984875447971917856768.0L,
+    218054639772618074103918318492639949832541424857847525973689094242831096606721142712632506945896448.0L,
+    1035184782769221379.0L,
+    20229959242348674822030474865930581759882432185790556800837709536659306775612115303354290565630013099091822016569802752.0L,
+    48688062002166777197217906565531932202748743487730562775775885775077288260863868471270436338269362633469095873857458641986964902395586782692041797794791424.0L,
+    38974159722814402882041466859823829059112658796999627209873147217197515116287035613100423934964813946613319590312148992.0L,
+    195268331869690963115301358617419463247405494910442809797401817422757888.0L,
+    131384791058457562832910671881942611444639653628436820141165072497889292487990472973483579015168.0L,
+    1334982489788592107381730508641253982208.0L,
+    2146.0L,
+    25165296015221802429839839397412864.0L,
+    6254.0L
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testldbl_575 (s_575[i]) != ldbl_575[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testldblu_575 (u_575[i]) != ldblu_575[i])
+      __builtin_abort ();
+#endif
+#endif
+#if __FLT128_MANT_DIG__ == 113
+#if __BITINT_MAXWIDTH__ >= 135
+  static _Float128 flt128_135[] = {
+    -39242093.0F128,
+    -36246971635108657318127321.0F128,
+    -816440703352.0F128,
+    8409360.0F128,
+    231875.0F128,
+    -1859.0F128,
+    8123250453541347379290840008816194560.0F128,
+    42642091.0F128,
+    -2499664813007708583619356686.0F128,
+    -14022533493907734339644.0F128,
+    737816709430180009697449492.0F128,
+    3094418595787172583521548578719419.0F128,
+    84096.0F128,
+    -3856393637064417.0F128,
+    5494.0F128,
+    -7227655824382622730861.0F128,
+    185250722103742953.0F128,
+    -266695839223233222300219080587185440.0F128,
+    124.0F128,
+    -4540724906728461994579131745203067.0F128,
+    -34474123.0F128,
+    6171186.0F128,
+    -1738448518309495501564259945530043904.0F128,
+    3714.0F128,
+    22759310366655438105064084505115488.0F128,
+    -461.0F128,
+    -1891475049610273521994429918325638430720.0F128,
+    -350.0F128,
+    3721759411106519959861226774340.0F128,
+    -42485872965031409753.0F128,
+    4362279409022137273490486629950.0F128,
+    521928664204421037572709995195346190336.0F128,
+    -50129.0F128,
+    -21525556783117336078661729.0F128
+  };
+  static _Float128 flt128u_135[] = {
+    773802493804221964748670742461281075200.0F128,
+    897485218654369665002411485681173.0F128,
+    37306898634990773758633.0F128,
+    3.0F128,
+    920156.0F128,
+    15230973698181139105641901258312096.0F128,
+    1383843491123931387484696.0F128,
+    143810081711544975903357370071668192.0F128,
+    83615891310230331473978.0F128,
+    1239150390.0F128,
+    39792042288.0F128,
+    20985035121604.0F128,
+    3700707.0F128,
+    14510535740825.0F128,
+    5675982879048653163399531637816917.0F128,
+    593909622129190124122830.0F128,
+    413008891327830587264.0F128,
+    34694483328.0F128,
+    592129.0F128,
+    2649.0F128,
+    154468451808267466822214091328849.0F128,
+    8905088171048376399858691570634230595584.0F128,
+    456.0F128,
+    12101.0F128,
+    5879086272.0F128,
+    115170058487623.0F128,
+    2274163249406113742515726136586945953792.0F128,
+    63923152267905666653.0F128,
+    624302860090054295150365837280525221888.0F128,
+    9.0F128,
+    5703520721951508439418.0F128,
+    44653119094.0F128,
+    1440439605268989101.0F128,
+    3496654014361.0F128,
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testflt128_135 (s_135[i]) != flt128_135[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testflt128u_135 (u_135[i]) != flt128u_135[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static _Float128 flt128_192[] = {
+    81945579384314684613279565479277936640.0F128,
+    1640150770700583136800158704601080.0F128,
+    432402469012491481987292073086668.0F128,
+    -15369197386440508323548800500962985275185701060608.0F128,
+    217705797486262.0F128,
+    1.0F128,
+    -150837356854711044278780637.0F128,
+    1247354027519369533750440146304.0F128,
+    -700073531555662209687924602081.0F128,
+    -441651351073606706893667405889558413312.0F128,
+    -743993151249791392844844248857961088.0F128,
+    1681039.0F128,
+    -170386616439159353410812029301398240755712.0F128,
+    -97703172400304820221345002831889.0F128,
+    9.0F128,
+    7277656199366069102639319241893.0F128,
+    7201222364.0F128,
+    -4671533967546296507223686237333335.0F128,
+    13311155734490577635922550.0F128,
+    76150533189365685907637983428512210753683456.0F128,
+    -283560863483321465221194695455688622080.0F128,
+    6438368552004797088499844257634549357780509986390016.0F128,
+    1122038765213390728664343086041576.0F128,
+    -9541613313421359977755878156940.0F128,
+    21551012076757076795102244535269248.0F128,
+    -4794294047755173531367558272.0F128,
+    -5708612827808554221.0F128,
+    -2649648007071280662902443553973167373493993472.0F128,
+    -35698660478241255546377.0F128,
+    -79587921140918.0F128,
+    469393710173925646.0F128,
+    -261330983098092746969723637867599366653101971873988608.0F128,
+    -115.0F128,
+    -1717706681396.0F128
+  };
+  static _Float128 flt128u_192[] = {
+    87197051833867272589618945858714289326891466752.0F128,
+    175207476610687227705633653396153448946982933495808.0F128,
+    289472685412214318981767004188.0F128,
+    58352315342320048378103056601781215690752.0F128,
+    68512267071922032916894194298300226631128387158016.0F128,
+    8654067584750856592691725728280108697911296.0F128,
+    57027948061283099317671673937496946996412416.0F128,
+    512829256101.0F128,
+    8815296701808550493421309771596155584512.0F128,
+    1918805208198312310092547265227.0F128,
+    99680639255733807.0F128,
+    313647272226958893709907781719.0F128,
+    534434342549592762863366619879590707855360.0F128,
+    1751643652514709.0F128,
+    24084146046683127013882581681582088.0F128,
+    1282076.0F128,
+    13590701668411111769.0F128,
+    62207549230439503653.0F128,
+    144040025133692457990548614076288499712.0F128,
+    11981724905403945793356785358565397335132602368.0F128,
+    1823479497818478859136796209626919944362858664695955456.0F128,
+    4649.0F128,
+    2095541338428713427585867932062430298743231209275392.0F128,
+    605377488765896342050766363050545174870818291712.0F128,
+    11488350477184223.0F128,
+    9492972359709013710789022084605392379617455653257216.0F128,
+    36826148417259.0F128,
+    554404239122129842026250702689.0F128,
+    2804528919100.0F128,
+    127.0F128,
+    66823885107232870336040073990324.0F128,
+    297736625249.0F128,
+    3701132312864550550157874952341371337719347203092250624.0F128,
+    107247048428.0F128
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testflt128_192 (s_192[i]) != flt128_192[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testflt128u_192 (u_192[i]) != flt128u_192[i])
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static _Float128 flt128_575[] = {
+    822555268170764275096048134868384975231305202380698070398256893835345920.0F128,
+    -960580267694575830808697063169243925424347053477730475548747760281578375092219925810414573005477242346668032.0F128,
+    33504080263976494448954627475165766133582184724974885918953650948043300306793972216863395126909133067122418159809305365193504587776.0F128,
+    275983725374553564148936957707321540608.0F128,
+    5534912144897227754137156977371639095192412221957522338641107839687274928618580082609389790489874004597965113744368228739650952266120186965187634240183436521269153476116480.0F128,
+    1412920302762671055711845665320769739585982745090302228751251561257591917233120715027663177911819317605963828665882521916923707392.0F128,
+    -262974997977953570994865210107604174211285573449595140085961138156042539763761152.0F128,
+    -92488905333378799268618025132022457141142846570320249542701164032605273639863975936.0F128,
+    242604167696163732697906496386839380754432.0F128,
+    -3523803651131338645439245946293.0F128,
+    -5147220779398204849222374563179412133730483913244844947741095427844771020506369407923839149503287374038736861390994705329184147880909168291858806583886610432.0F128,
+    -126995956651641937332005246092202760396991711130361124184051111962275756857424469430504968451843424256.0F128,
+    8137926360495.0F128,
+    -15994393111836746332671329788635258.0F128,
+    -277068516868681202554828866807401284897736575250260327862135188106751832616437168642952110232327515317207040.0F128,
+    12643256666940489874033990964997310311509982541568852403544135424197738165753506401380990976.0F128,
+    197250790460297242975596746662998771990764978176.0F128,
+    2003391279347376998472.0F128,
+    -199877387236416475658211887841938078116745459015943716864.0F128,
+    683783725793437346966376731991835350216389560350369725901413018663785858547865033572885485563448799017573485017347368404816660544180811049467904.0F128,
+    13527430925075101894748577029275390536381026872613143284679822016512.0F128,
+    539267000300803493510458136103246882259019817595681864105782809148075261013592028608675098514927074416787456.0F128,
+    25132435181738021677664552852329012575221796248107329953164935247044160207130354864627942162432.0F128,
+    -24501129715197464074815490290653.0F128,
+    -26621511339033230503491791253914733242220544.0F128,
+    219726795681725191949095808767196088027323027463729625239897408186970438805069530998505472.0F128,
+    142706206515281341916417852232439290189748851664859866651282555201592789754864805842059991220441617268736.0F128,
+    -1272097813202031618710288063584910381967486400606337174633920325485235383013308628992.0F128,
+    104580584066897755717617980935051170305797669115984125432799736278374300011999760896397625133977276440200975782266619201323008.0F128,
+    -10163452549280413821027501723364683055953700133730297193238300661557892457130680244331940377983114543931479834308368189407852102459256936746559008186557007921152.0F128,
+    -1462817702603947401421838547412731245576629932826602450317303690796368281340685443455159080277069867736216994863788876540424722028886424027136.0F128,
+    -1004473459167555639043426932334304453164309296447488.0F128,
+    383945882095471823332216311173956128684860565442900813809054240626596219564185981250247929792487147923720686617427927221102360379955085312.0F128,
+    147266903774875157001493887893421894471609745020407505370480640.0F128
+  };
+  static _Float128 flt128u_575[] = {
+    340315902121482071031.0F128,
+    9193736781349493374149172723522049989237037596672.0F128,
+    121133456126887617775249483436586393077503068671965236572261282102895601164339904512.0F128,
+    1253811282917666038992497.0F128,
+    279807426767721176279253888473523001912720192704990464927491539867791671603022985691136.0F128,
+    4763192686302836059965684032432862322867369410560.0F128,
+    19433750446582365356875213925336732513880424973437320406724993874129714386347241802580335495811686203392.0F128,
+    8615689860907972907203187028321797859877386013383767881250826182682427913148188824772809437492048511967461413139431335435390421932095562711387007040942408370667651072.0F128,
+    126055589776274659515356020606486933259536337762793314648917307764206055685941649262118277933003906979239670868955670671312897309994725986907806357486538234999603200.0F128,
+    34636325529158225079379169125604750695785810484482739930710385070599465675115027923570016766582469711320673437462251387815460864.0F128,
+    2295982750677874548137685137480985746757882615322149650432.0F128,
+    22288650253829612832302454550260146257726013440.0F128,
+    61551827.0F128,
+    948415991495935226718622697967024239258764159275032239689900905479457935391294424204960412146551901344394652585549587358170098052366336.0F128,
+    7599947921908039117808602805272900645537701743475990438308994289927813380793983514791799884349440.0F128,
+    3064098671438076295010586583414642942579869059363710430687661115226367832562244997089071440248013792356608654440236754254640577193658338300579944911876551907294312398848.0F128,
+    26163216482276433755253744705785501643665555701904644656073951369763934041725743914298920119135277939192496128.0F128,
+    1083530146709801198539441549736949272615707866142747675126337487600174059213906750437224937669383865518151504262638122920877713397402240447485732907072897115226112.0F128,
+    241446995995054305582384233456322524985744615968604160.0F128,
+    224319712854.0F128,
+    1851847735563213275.0F128,
+    3517907813008404838784133683859253760.0F128,
+    57026061017409510123542169719303831161096310734855482941686454210514675616939245568.0F128,
+    218054639772618074096850378810323562095353038053985944696037552052916135283715799629412817614929920.0F128,
+    1035184782769221379.0F128,
+    20229959242348674822834301353257600173306714018005091825486635184900252137125196224692061477495530409091482128339697664.0F128,
+    48688062002166777196074419660880812364369698930536203875840059698600317657977119368587792531578529291152047948106379901115479025495192432692355212848922624.0F128,
+    38974159722814402881994907079236517852974167599450685098668223152330886687288507721175784841029076691372600892770484224.0F128,
+    195268331869690963115384309853070885336463825745125450367383853651197952.0F128,
+    131384791058457562831689753115846222841883611947373268365763186683292391066729693706687923355648.0F128,
+    1334982489788592107403503927792629186560.0F128,
+    2146.0F128,
+    25165296015221802429838428736907888.0F128,
+    6254.0F128
+  };
+  for (int i = 0; i < 34; ++i)
+    if (testflt128_575 (s_575[i]) != flt128_575[i])
+      __builtin_abort ();
+  for (int i = 0; i < 34; ++i)
+    if (testflt128u_575 (u_575[i]) != flt128u_575[i])
+      __builtin_abort ();
+#endif
+#endif
+}
--- gcc/testsuite/gcc.dg/torture/bitint-25.c.jj	2023-07-27 15:03:24.248234257 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-25.c	2023-07-27 15:03:24.248234257 +0200
@@ -0,0 +1,91 @@ 
+/* PR c/102989 */
+/* { dg-do run { target { bitint && float16_runtime } } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+/* { dg-add-options float16 } */
+
+int
+main ()
+{
+#if __FLT16_MANT_DIG__ == 11
+  static volatile _Float16 s[] = {
+    0.0F16,
+    42.0F16,
+    -65504.0F16,
+    65504.0F16
+  };
+  static volatile _Float16 u[] = {
+    0.0F16,
+    1.0F16,
+    178.0F16,
+    65504.0F16
+  };
+#if __BITINT_MAXWIDTH__ >= 135
+  static volatile _BitInt(135) s_135[] = {
+    0wb,
+    42wb,
+    -65504wb,
+    65504wb
+  };
+  static volatile unsigned _BitInt(135) u_135[] = {
+    0uwb,
+    1uwb,
+    178uwb,
+    65504uwb
+  };
+  for (int i = 0; i < 4; ++i)
+    {
+      if (s[i] != (_Float16) s_135[i]
+	  || u[i] != (_Float16) u_135[i]
+	  || (_BitInt(135)) s[i] != s_135[i]
+	  || (unsigned _BitInt(135)) u[i] != u_135[i])
+	__builtin_abort ();
+    }
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  static volatile _BitInt(192) s_192[] = {
+    0wb,
+    42wb,
+    -65504wb,
+    65504wb
+  };
+  static volatile unsigned _BitInt(192) u_192[] = {
+    0uwb,
+    1uwb,
+    178uwb,
+    65504uwb
+  };
+  for (int i = 0; i < 4; ++i)
+    {
+      if (s[i] != (_Float16) s_192[i]
+	  || u[i] != (_Float16) u_192[i]
+	  || (_BitInt(192)) s[i] != s_192[i]
+	  || (unsigned _BitInt(192)) u[i] != u_192[i])
+	__builtin_abort ();
+    }
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static volatile _BitInt(575) s_575[] = {
+    0wb,
+    42wb,
+    -65504wb,
+    65504wb
+  };
+  static volatile unsigned _BitInt(575) u_575[] = {
+    0uwb,
+    1uwb,
+    178uwb,
+    65504uwb
+  };
+  for (int i = 0; i < 4; ++i)
+    {
+      if (s[i] != (_Float16) s_575[i]
+	  || u[i] != (_Float16) u_575[i]
+	  || (_BitInt(575)) s[i] != s_575[i]
+	  || (unsigned _BitInt(575)) u[i] != u_575[i])
+	__builtin_abort ();
+    }
+#endif
+#endif
+}
--- gcc/testsuite/gcc.dg/torture/bitint-26.c.jj	2023-07-27 15:03:24.248234257 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-26.c	2023-07-27 15:03:24.248234257 +0200
@@ -0,0 +1,66 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) _BitInt(135)
+test_135 (_BitInt(135) x)
+{
+  return x;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) unsigned _BitInt(192)
+test_192 (unsigned _BitInt(192) x)
+{
+  return x;
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) _BitInt(575)
+test_575 (_BitInt(575) x)
+{
+  return x;
+}
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 135
+  if (test_135 (-3544625980220396993429741165699996713118wb)
+      != -3544625980220396993429741165699996713118wb)
+    __builtin_abort ();
+  if (test_135 (2169804wb) != 2169804wb)
+    __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  if (test_192 (3548247468860296534428690122730090696161878417599647607527uwb)
+      != 3548247468860296534428690122730090696161878417599647607527uwb)
+    __builtin_abort ();
+  if (test_192 (2169804wb) != 2169804wb)
+    __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  if (test_575 (-33874713055088145128482141398907153733216500583643955589065159154103468056485975553675944430696955474989655597693729139818286384955989466009330817447458608627989731550807841wb)
+      != -33874713055088145128482141398907153733216500583643955589065159154103468056485975553675944430696955474989655597693729139818286384955989466009330817447458608627989731550807841wb)
+    __builtin_abort ();
+  if (test_575 (-3433547832854987708194667330190358661244810661613962474981319303539871wb)
+      != -3433547832854987708194667330190358661244810661613962474981319303539871wb)
+    __builtin_abort ();
+  if (test_575 (-49693319wb) != -49693319wb)
+    __builtin_abort ();
+  if (test_575 (57563058931861084391041643822550577259264793697002277417254009715684553274763772399490655207001200602249198262962055591804634113396033194657392511369609233430583407788096333wb)
+      != 57563058931861084391041643822550577259264793697002277417254009715684553274763772399490655207001200602249198262962055591804634113396033194657392511369609233430583407788096333wb)
+    __builtin_abort ();
+  if (test_575 (158093724114624905837287422406159616673122916308832353wb)
+      != 158093724114624905837287422406159616673122916308832353wb)
+    __builtin_abort ();
+  if (test_575 (3807354285642wb) != 3807354285642wb)
+    __builtin_abort ();
+#endif
+}
--- gcc/testsuite/gcc.dg/torture/bitint-27.c.jj	2023-07-27 15:03:24.245234299 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-27.c	2023-07-27 15:03:24.245234299 +0200
@@ -0,0 +1,373 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+int expected;
+
+__attribute__((noipa)) void
+test (int x, int y, int z)
+{
+  (void) x;
+  (void) y;
+  if (z != expected)
+    __builtin_abort ();
+}
+
+#if __BITINT_MAXWIDTH__ >= 135
+__attribute__((noipa)) void
+test_135 (_BitInt(135) a)
+{
+  switch (a)
+    {
+    case -33841133710wb:
+      test (1, 2, 1); break;
+    case -55283508608004252890371630137wb:
+      test (2, 3, 2); break;
+    case -1065119162618253595246332535wb:
+      test (3, 4, 3); break;
+    case 265225687803630460135wb:
+      test (4, 5, 4); break;
+    case 12802219454007328327057691wb:
+      test (5, 6, 5); break;
+    case -59157301wb:
+      test (6, 7, 6); break;
+    case 28029296819738wb:
+      test (7, 8, 7); break;
+    case 23771967952817687922824184198772908114wb:
+      test (8, 9, 8); break;
+    case -528wb:
+      test (10, 9, 9); break;
+    case -21743705968wb:
+      test (11, 8, 10); break;
+    case 3761322442803929370621734404255158wb:
+      test (12, 7, 11); break;
+    case 7581882536870984828946588790215963wb:
+      test (13, 6, 12); break;
+    case -3601335158354600803149652143011wb:
+      test (14, 5, 13); break;
+    case 104802210847691888333394846958wb:
+      test (15, 4, 14); break;
+    case 145823237253137988087297wb:
+      test (16, 3, 15); break;
+    case 3871725619091wb:
+      test (17, 2, 16); break;
+    case -480987385702wb:
+      test (18, 1, 17); break;
+    case -1084968414543030wb:
+      test (19, 0, 18); break;
+    case -12928976wb:
+      test (20, -1, 19); break;
+    case -268774wb:
+      test (21, -2, 20); break;
+    case 532464351235328336949014678wb:
+      test (22, -3, 21); break;
+    case -1145290618187237284790705482290160wb:
+      test (23, -4, 22); break;
+    case -249459466889744wb:
+      test (24, -5, 23); break;
+    case -1403065236wb:
+      test (25, 1, 24); break;
+    case -25456270573862478377606wb:
+      test (26, 2, 25); break;
+    case 33340794611915791wb:
+      test (27, 3, 26); break;
+    case -674079586163272813wb:
+      test (28, 4, 27); break;
+    case -41952758959718119236303556590897001668wb:
+      test (29, 5, 28); break;
+    case 2947453415wb:
+      test (30, 6, 29); break;
+    case -677wb:
+      test (31, 7, 30); break;
+    case -463646803422851872253575745194919wb:
+      test (32, 8, 31); break;
+    case -71367919591514155952975401251963194wb:
+      test (33, 7, 32); break;
+    case -14346961913818709867962386609601wb:
+      test (34, 6, 33); break;
+    case 690wb:
+      test (35, 5, 34); break;
+    default:
+      test (36, 4, 35); break;
+      break;
+    }
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 192
+__attribute__((noipa)) int
+test_192 (unsigned _BitInt(192) a)
+{
+  switch (a)
+    {
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 48:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 49:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 50:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 51:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 52:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 53:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 54:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 55:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 56:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 57:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 65:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 66:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 67:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 68:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 69:
+    case 1505160143063006983093195408894239764415303566721254616896uwb + 70:
+      return 1;
+    default:
+      return 0;
+    }
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 574
+__attribute__((noipa)) void
+test_574 (unsigned _BitInt(574) a)
+{
+  switch (a)
+    {
+    case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246uwb:
+      test (22, -3, 1); break;
+    case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891247uwb:
+      test (23, -4, 2); break;
+    case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891248uwb:
+      test (24, -5, 3); break;
+    case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891249uwb:
+      test (25, 1, 4); break;
+    case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891250uwb:
+      test (26, 2, 5); break;
+    case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891251uwb:
+      test (27, 3, 6); break;
+    case 6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891257uwb:
+      test (28, 4, 7); break;
+    default:
+      test (29, 5, 8); break;
+      break;
+    }
+}
+#endif
+
+#if __BITINT_MAXWIDTH__ >= 575
+__attribute__((noipa)) void
+test_575 (_BitInt(575) a)
+{
+  switch (a)
+    {
+    case 57158236877324191282832099954551676419657688516114213070568173374483038461911230482096734270573673572006270803057167488583704wb:
+      test (1, 2, 1); break;
+    case 55932752002978259755258693759201176077252755664748wb:
+      test (2, 3, 2); break;
+    case -4218363291370143377367234486177453689054229233132334373089588356145503900632432151470684730299990106009156255994430506676467506300235609892554834254413957477779209219867825wb:
+      test (3, 4, 3); break;
+    case -19380856704203460544565443028wb:
+      test (4, 5, 4); break;
+    case 37691457600250454282496246135038751153145234859661859831059667050412054918743986000946778819692986258358820458161034213280wb:
+      test (5, 6, 5); break;
+    case 827003152758795459486819489974390601625339063627401335603123746581523657253393870961575744071183196915560771288079061574485309986042624106685495948664669wb:
+      test (6, 7, 6); break;
+    case 2001882657256786505981789524889669355393757203160978wb:
+      test (7, 8, 7); break;
+    case 2273951349206310803215316642428483249009583047771549wb:
+      test (8, 9, 8); break;
+    case -63640037492105525397657594648433413082358686497544854829581174487203243151113011293858381773246wb:
+      test (10, 9, 9); break;
+    case -5043989193130150016980754467018673356423436330428309162407512361831163237wb:
+      test (11, 8, 10); break;
+    case -86904413785414524864201428752820860524832869110219388825241400306401wb:
+      test (12, 7, 11); break;
+    case -7159581406wb:
+      test (13, 6, 12); break;
+    case -430416863734662045942802859497964wb:
+      test (14, 5, 13); break;
+    case -282099469984391093781566wb:
+      test (15, 4, 14); break;
+    case 259191242782270578340350840252447902477249511321245827805053349778984004438373803812874430619356951005300429wb:
+      test (16, 3, 15); break;
+    case -17427431700557396203431wb:
+      test (17, 2, 16); break;
+    case -324305733281944621534wb:
+      test (18, 1, 17); break;
+    case 39167932287702074309519944575154814029176054304655900600154735991016090154633448789399330wb:
+      test (19, 0, 18); break;
+    case 198828227576458371467364915441164050473274232622009526563856039032wb:
+      test (20, -1, 19); break;
+    case 7522018863556878842079508104211164618555wb:
+      test (21, -2, 20); break;
+    case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246wb:
+      test (22, -3, 21); break;
+    case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891247wb:
+      test (23, -4, 22); break;
+    case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891248wb:
+      test (24, -5, 23); break;
+    case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891249wb:
+      test (25, 1, 24); break;
+    case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891250wb:
+      test (26, 2, 25); break;
+    case -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891251wb:
+      test (27, 3, 26); break;
+    case 25232715496072790939146860623749108256506615788345509143038026592127702780903347954226870163752427434085269890371577229233150314692259399042327414965711510629wb:
+      test (28, 4, 27); break;
+    case 21376200838998904075479297127185224975235208544658573531790808467114261325514834503383673531634166234wb:
+      test (29, 5, 28); break;
+    case -12950763061001084589012736558965423479147155000678492177259830314151681149963956790935448632739537613359984550457633150573373wb:
+      test (30, 6, 29); break;
+    case -2588834879960231787797472372536501710262304078735816335394876043103825991870347510560085648304946wb:
+      test (31, 7, 30); break;
+    case -2701643349985817058465875459099740236751728453427684wb:
+      test (32, 8, 31); break;
+    case 5836201004021438163265930908885473220627459728279406489088525555799694670629946003808237930825748wb:
+      test (33, 7, 32); break;
+    case 44108809764408326456612205445124618284924483635588993217673301668963284129265963564132943970751645671455967029559660507196902756491684232894669648136319146730wb:
+      test (34, 6, 33); break;
+    case 2296104972770686523043774188826290903188890257660332269411533641473619626906874515994186550107564291006924533677263136416982312042wb:
+      test (35, 5, 34); break;
+    case 2194074380385385359486226752708738wb:
+      test (36, 4, 35); break;
+    case 538995045833371297308662695915673724930785814100527903453604wb:
+      test (37, 3, 36); break;
+    case 2085626377217975761550063150555904902911153438008474368944585344266562733501648381wb:
+      test (38, 2, 37); break;
+    case -33688835949886075020354777490957071wb:
+      test (39, 1, 38); break;
+    case 1391419408329070356813886663340861253838000363084420822349730519562112746630131027735880100996653wb:
+      test (40, 0, 39); break;
+    default:
+      test (41, -1, 40); break;
+      break;
+    }
+}
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 135
+  static _BitInt(135) a_135[] = {
+    -33841133710wb,
+    -55283508608004252890371630137wb,
+    -1065119162618253595246332535wb,
+    265225687803630460135wb,
+    12802219454007328327057691wb,
+    -59157301wb,
+    28029296819738wb,
+    23771967952817687922824184198772908114wb,
+    -528wb,
+    -21743705968wb,
+    3761322442803929370621734404255158wb,
+    7581882536870984828946588790215963wb,
+    -3601335158354600803149652143011wb,
+    104802210847691888333394846958wb,
+    145823237253137988087297wb,
+    3871725619091wb,
+    -480987385702wb,
+    -1084968414543030wb,
+    -12928976wb,
+    -268774wb,
+    532464351235328336949014678wb,
+    -1145290618187237284790705482290160wb,
+    -249459466889744wb,
+    -1403065236wb,
+    -25456270573862478377606wb,
+    33340794611915791wb,
+    -674079586163272813wb,
+    -41952758959718119236303556590897001668wb,
+    2947453415wb,
+    -677wb,
+    -463646803422851872253575745194919wb,
+    -71367919591514155952975401251963194wb,
+    -14346961913818709867962386609601wb,
+    690wb
+  };
+  for (int i = 0; i < 34; ++i)
+    {
+      expected = i + 1;
+      test_135 (a_135[i]);
+      expected = 35;
+      test_135 (a_135[i] - 1);
+      test_135 (a_135[i] + 1);
+    }
+#endif
+#if __BITINT_MAXWIDTH__ >= 192
+  if (test_192 (0uwb)
+      || test_192 (1505160143063006983093195408894239764415303566721254616896uwb)
+      || test_192 (1505160143063006983093195408894239764415303566721254616896uwb + 47)
+      || test_192 (1505160143063006983093195408894239764415303566721254616896uwb + 71)
+      || test_192 (-1uwb))
+    __builtin_abort ();
+  for (int i = 48; i <= 70; ++i)
+    if (test_192 (1505160143063006983093195408894239764415303566721254616896uwb + i) != (i < 58 || i > 64))
+      __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 574
+  expected = 8;
+  test_574 (0uwb);
+  test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246uwb - 0x10000000000000000uwb);
+  test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891245uwb);
+  test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891258uwb);
+  test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246uwb + 0x10000000000000000uwb);
+  test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891258uwb + 0x10000000000000000uwb);
+  for (int i = 0; i <= 11; ++i)
+    {
+      expected = i == 11 ? 7 : i > 5 ? 8 : i + 1;
+      test_574 (6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246uwb + i);
+    }
+#endif
+#if __BITINT_MAXWIDTH__ >= 575
+  static _BitInt(575) a_575[] = {
+    57158236877324191282832099954551676419657688516114213070568173374483038461911230482096734270573673572006270803057167488583704wb,
+    55932752002978259755258693759201176077252755664748wb,
+    -4218363291370143377367234486177453689054229233132334373089588356145503900632432151470684730299990106009156255994430506676467506300235609892554834254413957477779209219867825wb,
+    -19380856704203460544565443028wb,
+    37691457600250454282496246135038751153145234859661859831059667050412054918743986000946778819692986258358820458161034213280wb,
+    827003152758795459486819489974390601625339063627401335603123746581523657253393870961575744071183196915560771288079061574485309986042624106685495948664669wb,
+    2001882657256786505981789524889669355393757203160978wb,
+    2273951349206310803215316642428483249009583047771549wb,
+    -63640037492105525397657594648433413082358686497544854829581174487203243151113011293858381773246wb,
+    -5043989193130150016980754467018673356423436330428309162407512361831163237wb,
+    -86904413785414524864201428752820860524832869110219388825241400306401wb,
+    -7159581406wb,
+    -430416863734662045942802859497964wb,
+    -282099469984391093781566wb,
+    259191242782270578340350840252447902477249511321245827805053349778984004438373803812874430619356951005300429wb,
+    -17427431700557396203431wb,
+    -324305733281944621534wb,
+    39167932287702074309519944575154814029176054304655900600154735991016090154633448789399330wb,
+    198828227576458371467364915441164050473274232622009526563856039032wb,
+    7522018863556878842079508104211164618555wb,
+    -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891246wb,
+    -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891247wb,
+    -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891248wb,
+    -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891249wb,
+    -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891250wb,
+    -6286965391667017312339071741838237504698922691411382973783611300502970166307629280084891251wb,
+    25232715496072790939146860623749108256506615788345509143038026592127702780903347954226870163752427434085269890371577229233150314692259399042327414965711510629wb,
+    21376200838998904075479297127185224975235208544658573531790808467114261325514834503383673531634166234wb,
+    -12950763061001084589012736558965423479147155000678492177259830314151681149963956790935448632739537613359984550457633150573373wb,
+    -2588834879960231787797472372536501710262304078735816335394876043103825991870347510560085648304946wb,
+    -2701643349985817058465875459099740236751728453427684wb,
+    5836201004021438163265930908885473220627459728279406489088525555799694670629946003808237930825748wb,
+    44108809764408326456612205445124618284924483635588993217673301668963284129265963564132943970751645671455967029559660507196902756491684232894669648136319146730wb,
+    2296104972770686523043774188826290903188890257660332269411533641473619626906874515994186550107564291006924533677263136416982312042wb,
+    2194074380385385359486226752708738wb,
+    538995045833371297308662695915673724930785814100527903453604wb,
+    2085626377217975761550063150555904902911153438008474368944585344266562733501648381wb,
+    -33688835949886075020354777490957071wb,
+    1391419408329070356813886663340861253838000363084420822349730519562112746630131027735880100996653wb
+  };
+  for (int i = 0; i < 39; ++i)
+    {
+      expected = i + 1;
+      test_575 (a_575[i]);
+      expected = 40;
+      if (i < 20 || i >= 25)
+	test_575 (a_575[i] - 1);
+      if (i <= 20 || i > 25)
+	test_575 (a_575[i] + 1);
+    }
+#endif
+}
--- gcc/testsuite/gcc.dg/torture/bitint-28.c.jj	2023-07-27 15:03:24.246234285 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-28.c	2023-07-27 15:03:24.246234285 +0200
@@ -0,0 +1,20 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#include "../../c-c++-common/torture/builtin-arith-overflow-1.h"
+
+#define U(s, op) op
+TESTS (_BitInt(19), (-262143wb - 1), 262143wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+
+int
+main ()
+{
+  TESTS (_BitInt(19), (-262143wb - 1), 262143wb)
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-29.c.jj	2023-07-27 15:03:24.247234271 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-29.c	2023-07-27 15:03:24.247234271 +0200
@@ -0,0 +1,24 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 119
+#include "../../c-c++-common/torture/builtin-arith-overflow-1.h"
+
+#define U(s, op) op
+TESTS (_BitInt(119), (-332306998946228968225951765070086143wb - 1), 332306998946228968225951765070086143wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 119
+  TESTS (_BitInt(119), (-332306998946228968225951765070086143wb - 1), 332306998946228968225951765070086143wb)
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-30.c.jj	2023-07-27 15:03:24.250234229 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-30.c	2023-07-27 15:03:24.250234229 +0200
@@ -0,0 +1,19 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#include "../../c-c++-common/torture/builtin-arith-overflow-12.h"
+
+TESTS (_BitInt(19), (-262143wb - 1), 262143wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+
+int
+main ()
+{
+  TESTS (_BitInt(19), (-262143wb - 1), 262143wb)
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-31.c.jj	2023-07-27 15:03:24.248234257 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-31.c	2023-07-27 15:03:24.247234271 +0200
@@ -0,0 +1,23 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 119
+#include "../../c-c++-common/torture/builtin-arith-overflow-12.h"
+
+TESTS (_BitInt(119), (-332306998946228968225951765070086143wb - 1), 332306998946228968225951765070086143wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 119
+  TESTS (_BitInt(119), (-332306998946228968225951765070086143wb - 1), 332306998946228968225951765070086143wb)
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-32.c.jj	2023-07-27 15:03:24.246234285 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-32.c	2023-07-27 15:03:24.246234285 +0200
@@ -0,0 +1,24 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 135
+#include "../../c-c++-common/torture/builtin-arith-overflow-1.h"
+
+#define U(s, op) op
+TESTS (_BitInt(135), (-21778071482940061661655974875633165533183wb - 1), 21778071482940061661655974875633165533183wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 135
+  TESTS (_BitInt(135), (-21778071482940061661655974875633165533183wb - 1), 21778071482940061661655974875633165533183wb)
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-33.c.jj	2023-07-27 15:03:24.249234243 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-33.c	2023-07-27 15:03:24.249234243 +0200
@@ -0,0 +1,24 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 192
+#include "../../c-c++-common/torture/builtin-arith-overflow-1.h"
+
+#define U(s, op) op
+TESTS (_BitInt(192), (-3138550867693340381917894711603833208051177722232017256447wb - 1), 3138550867693340381917894711603833208051177722232017256447wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 192
+  TESTS (_BitInt(192), (-3138550867693340381917894711603833208051177722232017256447wb - 1), 3138550867693340381917894711603833208051177722232017256447wb)
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-34.c.jj	2023-07-27 15:03:24.247234271 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-34.c	2023-07-27 15:03:24.247234271 +0200
@@ -0,0 +1,24 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 575
+#include "../../c-c++-common/torture/builtin-arith-overflow-1.h"
+
+#define U(s, op) op
+TESTS (_BitInt(575), (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 575
+  TESTS (_BitInt(575), (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb)
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-35.c.jj	2023-07-27 15:03:24.246234285 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-35.c	2023-07-27 15:03:24.245234299 +0200
@@ -0,0 +1,23 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 135
+#include "../../c-c++-common/torture/builtin-arith-overflow-12.h"
+
+TESTS (_BitInt(135), (-21778071482940061661655974875633165533183wb - 1), 21778071482940061661655974875633165533183wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 135
+  TESTS (_BitInt(135), (-21778071482940061661655974875633165533183wb - 1), 21778071482940061661655974875633165533183wb)
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-36.c.jj	2023-07-27 15:03:24.246234285 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-36.c	2023-07-27 15:03:24.246234285 +0200
@@ -0,0 +1,23 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 192
+#include "../../c-c++-common/torture/builtin-arith-overflow-12.h"
+
+TESTS (_BitInt(192), (-3138550867693340381917894711603833208051177722232017256447wb - 1), 3138550867693340381917894711603833208051177722232017256447wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 192
+  TESTS (_BitInt(192), (-3138550867693340381917894711603833208051177722232017256447wb - 1), 3138550867693340381917894711603833208051177722232017256447wb)
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-37.c.jj	2023-07-27 15:03:24.249234243 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-37.c	2023-07-27 15:03:24.249234243 +0200
@@ -0,0 +1,23 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 575
+#include "../../c-c++-common/torture/builtin-arith-overflow-12.h"
+
+TESTS (_BitInt(575), (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb)
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 575
+  TESTS (_BitInt(575), (-61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1), 61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb)
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-38.c.jj	2023-07-27 15:03:24.248234257 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-38.c	2023-07-27 15:03:24.248234257 +0200
@@ -0,0 +1,56 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 575
+#include "../../c-c++-common/torture/builtin-arith-overflow.h"
+
+#ifdef __SIZEOF_INT128__
+#define WTYPE __int128
+#else
+#define WTYPE long long int
+#endif
+
+#define TESTS \
+T (100, signed _BitInt(38), signed char, unsigned _BitInt(162), -1wb, 0, -1wb, add, 1) \
+T (101, unsigned char, unsigned _BitInt(38), unsigned _BitInt(162), 5, 5wb, 10wb, add, 0) \
+T (102, signed _BitInt(38), unsigned short, unsigned _BitInt(162), 5wb, 5, 0wb, sub, 0) \
+T (103, signed _BitInt(38), unsigned _BitInt(72), unsigned _BitInt(162), 5wb, 6wb, -1wb, sub, 1) \
+T (104, signed _BitInt(38), signed _BitInt(38), unsigned _BitInt(162), -1wb, -1wb, 1wb, mul, 0) \
+T (105, unsigned _BitInt(38), signed _BitInt(38), unsigned _BitInt(162), 17wb, -2wb, -34wb, mul, 1) \
+T (106, unsigned _BitInt(162), signed _BitInt(162), signed _BitInt(38), 5wb, -2wb, -10wb, mul, 0) \
+T (107, signed _BitInt(321), signed _BitInt(321), unsigned _BitInt(38), -3wb, 5wb, 2wb, add, 0) \
+T (108, signed _BitInt(321), int, unsigned _BitInt(38), -5wb, 3, -2wb, add, 1) \
+T (109, int, _BitInt(162), unsigned _BitInt(38), -3, 5wb, 2wb, add, 0) \
+T (110, unsigned _BitInt(38), unsigned _BitInt(38), unsigned _BitInt(162), 137438953471wb - 1, (unsigned _BitInt(38)) 137438953471wb + 4, -5wb, sub, 1) \
+T (111, signed _BitInt(315), signed _BitInt(315), unsigned, -1wb, 0wb, -1, add, 1) \
+T (112, signed _BitInt(315), signed _BitInt(315), unsigned, 5wb, 42wb, 47, add, 0) \
+T (113, signed _BitInt(315), signed _BitInt(315), unsigned WTYPE, -1wb, 0wb, -1, add, 1) \
+T (114, signed _BitInt(315), signed _BitInt(315), unsigned WTYPE, 15wb, 5wb, 20, add, 0)
+T (115, signed _BitInt(315), signed _BitInt(315), unsigned _BitInt(135), -1wb, 0wb, -1wb, add, 1) \
+T (116, signed _BitInt(315), signed _BitInt(315), unsigned _BitInt(135), 5wb, 125wb, 130wb, add, 0) \
+T (117, signed _BitInt(275), signed _BitInt(275), unsigned _BitInt(125), -1wb, 0wb, -1wb, add, 1) \
+T (118, signed _BitInt(275), signed _BitInt(275), unsigned _BitInt(125), 5wb, 125wb, 130wb, add, 0) \
+T (119, signed _BitInt(415), signed _BitInt(415), signed _BitInt(178), 95780971304118053647396689196894323976171195136475135wb, 95780971304118053647396689196894323976171195136475137wb, -191561942608236107294793378393788647952342390272950271wb - 1, add, 1) \
+T (120, signed _BitInt(415), signed _BitInt(415), signed _BitInt(178), 95780971304118053647396689196894323976171195136475135wb, 95780971304118053647396689196894323976171195136475136wb, 191561942608236107294793378393788647952342390272950271wb, add, 0) \
+T (121, signed _BitInt(439), signed _BitInt(439), signed _BitInt(192), 1569275433846670190958947355801916604025588861116008628223wb, 1569275433846670190958947355801916604025588861116008628225wb, -3138550867693340381917894711603833208051177722232017256447wb - 1, add, 1) \
+T (122, signed _BitInt(439), signed _BitInt(439), signed _BitInt(192), 1569275433846670190958947355801916604025588861116008628223wb, 1569275433846670190958947355801916604025588861116008628224wb, 3138550867693340381917894711603833208051177722232017256447wb, add, 0) \
+T (123, signed _BitInt(575), signed _BitInt(575), signed _BitInt(193), 3138550867693340381917894711603833208051177722232017256447wb, 3138550867693340381917894711603833208051177722232017256449wb, -6277101735386680763835789423207666416102355444464034512895wb - 1, add, 1) \
+T (124, signed _BitInt(575), signed _BitInt(575), signed _BitInt(193), 3138550867693340381917894711603833208051177722232017256447wb, 3138550867693340381917894711603833208051177722232017256448wb, 6277101735386680763835789423207666416102355444464034512895wb, add, 0)
+
+TESTS
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 575
+  TESTS
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-39.c.jj	2023-07-27 15:03:24.247234271 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-39.c	2023-07-27 15:03:24.247234271 +0200
@@ -0,0 +1,57 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=gnu2x" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 575
+#define OVFP
+#include "../../c-c++-common/torture/builtin-arith-overflow.h"
+
+#ifdef __SIZEOF_INT128__
+#define WTYPE __int128
+#else
+#define WTYPE long long int
+#endif
+
+#define TESTS \
+T (100, signed _BitInt(38), signed char, unsigned _BitInt(162), -1wb, 0, -1wb, add, 1) \
+T (101, unsigned char, unsigned _BitInt(38), unsigned _BitInt(162), 5, 5wb, 10wb, add, 0) \
+T (102, signed _BitInt(38), unsigned short, unsigned _BitInt(162), 5wb, 5, 0wb, sub, 0) \
+T (103, signed _BitInt(38), unsigned _BitInt(72), unsigned _BitInt(162), 5wb, 6wb, -1wb, sub, 1) \
+T (104, signed _BitInt(38), signed _BitInt(38), unsigned _BitInt(162), -1wb, -1wb, 1wb, mul, 0) \
+T (105, unsigned _BitInt(38), signed _BitInt(38), unsigned _BitInt(162), 17wb, -2wb, -34wb, mul, 1) \
+T (106, unsigned _BitInt(162), signed _BitInt(162), signed _BitInt(38), 5wb, -2wb, -10wb, mul, 0) \
+T (107, signed _BitInt(321), signed _BitInt(321), unsigned _BitInt(38), -3wb, 5wb, 2wb, add, 0) \
+T (108, signed _BitInt(321), int, unsigned _BitInt(38), -5wb, 3, -2wb, add, 1) \
+T (109, int, _BitInt(162), unsigned _BitInt(38), -3, 5wb, 2wb, add, 0) \
+T (110, unsigned _BitInt(38), unsigned _BitInt(38), unsigned _BitInt(162), 137438953471wb - 1, (unsigned _BitInt(38)) 137438953471wb + 4, -5wb, sub, 1) \
+T (111, signed _BitInt(315), signed _BitInt(315), unsigned, -1wb, 0wb, -1, add, 1) \
+T (112, signed _BitInt(315), signed _BitInt(315), unsigned, 5wb, 42wb, 47, add, 0) \
+T (113, signed _BitInt(315), signed _BitInt(315), unsigned WTYPE, -1wb, 0wb, -1, add, 1) \
+T (114, signed _BitInt(315), signed _BitInt(315), unsigned WTYPE, 15wb, 5wb, 20, add, 0)
+T (115, signed _BitInt(315), signed _BitInt(315), unsigned _BitInt(135), -1wb, 0wb, -1wb, add, 1) \
+T (116, signed _BitInt(315), signed _BitInt(315), unsigned _BitInt(135), 5wb, 125wb, 130wb, add, 0) \
+T (117, signed _BitInt(275), signed _BitInt(275), unsigned _BitInt(125), -1wb, 0wb, -1wb, add, 1) \
+T (118, signed _BitInt(275), signed _BitInt(275), unsigned _BitInt(125), 5wb, 125wb, 130wb, add, 0) \
+T (119, signed _BitInt(415), signed _BitInt(415), signed _BitInt(178), 95780971304118053647396689196894323976171195136475135wb, 95780971304118053647396689196894323976171195136475137wb, -191561942608236107294793378393788647952342390272950271wb - 1, add, 1) \
+T (120, signed _BitInt(415), signed _BitInt(415), signed _BitInt(178), 95780971304118053647396689196894323976171195136475135wb, 95780971304118053647396689196894323976171195136475136wb, 191561942608236107294793378393788647952342390272950271wb, add, 0) \
+T (121, signed _BitInt(439), signed _BitInt(439), signed _BitInt(192), 1569275433846670190958947355801916604025588861116008628223wb, 1569275433846670190958947355801916604025588861116008628225wb, -3138550867693340381917894711603833208051177722232017256447wb - 1, add, 1) \
+T (122, signed _BitInt(439), signed _BitInt(439), signed _BitInt(192), 1569275433846670190958947355801916604025588861116008628223wb, 1569275433846670190958947355801916604025588861116008628224wb, 3138550867693340381917894711603833208051177722232017256447wb, add, 0) \
+T (123, signed _BitInt(575), signed _BitInt(575), signed _BitInt(193), 3138550867693340381917894711603833208051177722232017256447wb, 3138550867693340381917894711603833208051177722232017256449wb, -6277101735386680763835789423207666416102355444464034512895wb - 1, add, 1) \
+T (124, signed _BitInt(575), signed _BitInt(575), signed _BitInt(193), 3138550867693340381917894711603833208051177722232017256447wb, 3138550867693340381917894711603833208051177722232017256448wb, 6277101735386680763835789423207666416102355444464034512895wb, add, 0)
+
+TESTS
+
+#undef T
+#define T(n, t1, t2, tr, v1, v2, vr, b, o) t##n##b ();
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 575
+  TESTS
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.dg/torture/bitint-40.c.jj	2023-07-27 15:03:24.247234271 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-40.c	2023-07-27 15:03:24.247234271 +0200
@@ -0,0 +1,40 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 323
+__attribute__((noipa)) _BitInt(323)
+foo (_BitInt(318) x, _BitInt(323) y)
+{
+  return x + y;
+}
+
+__attribute__((noipa)) _BitInt(323)
+bar (_BitInt(117) x, _BitInt(323) y)
+{
+  return x + y;
+}
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 323
+  if (foo (-27733041854193447641086572824547940096595738628642819753407953445763239714154199953745005898992wb,
+	   4767458710334760668834645815738583537909191474644120198636728988961922824468904018596948147773722wb)
+      != 4739725668480567221193559242914035597812595736015477378883321035516159584754749818643203141874730wb
+      || (foo (22167179033351019542845489620035412963406090796537167425591583962059414367893933412196721063711wb,
+	       5235750662037407195417484618645691209305675673195256409842928988743249911043551311451335001624960wb)
+	  != 5257917841070758214960330108265726622269081763991793577268520572705309325411445244863531722688671wb))
+    __builtin_abort ();
+  if (bar (-12653567664155974398995022748067044wb,
+	   7190977642064159111525225823679712940862545424809645152399787447341776579576645887978584020321431wb)
+      != 7190977642064159111525225823679712940862545424809645152399787434688208915420671488983561272254387wb
+      || (bar (30518211833575333685611432934770228wb,
+	       2152360419596992042662178082767272400451689654640037233902067223067458441134717528282349099466966wb)
+	  != 2152360419596992042662178082767272400451689654640037233902067253585670274710051213893782034237194wb))
+    __builtin_abort ();
+#endif
+}
--- gcc/testsuite/gcc.dg/torture/bitint-41.c.jj	2023-07-27 15:03:24.245234299 +0200
+++ gcc/testsuite/gcc.dg/torture/bitint-41.c	2023-07-27 15:03:24.245234299 +0200
@@ -0,0 +1,34 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c2x -pedantic-errors" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 256
+__attribute__((noipa)) _Bool
+test256 (_BitInt(256) *q)
+{
+  return __builtin_sub_overflow ((_BitInt(256)) 0, q[0], q + 1);
+}
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 256
+  static _BitInt(256) q256[] = {
+    45345032714412617256156490782169070529322290545773058110333871537162440472587wb,
+    0wb,
+    -45345032714412617256156490782169070529322290545773058110333871537162440472587wb,
+    -45345032714412617256156490782169070529322290545773058110333871537162440472587wb,
+    0wb,
+    45345032714412617256156490782169070529322290545773058110333871537162440472587wb,
+    -57896044618658097711785492504343953926634992332820282019728792003956564819967wb - 1,
+    0wb,
+    -57896044618658097711785492504343953926634992332820282019728792003956564819967wb - 1
+  };
+  for (int i = 0; i < 3; ++i)
+    if (test256 (q256 + 3 * i) != (i == 2) || q256[3 * i + 1] != q256[3 * i + 2])
+      __builtin_abort ();
+#endif
+}
--- gcc/testsuite/gcc.dg/ubsan/bitint-1.c.jj	2023-07-27 15:03:24.245234299 +0200
+++ gcc/testsuite/gcc.dg/ubsan/bitint-1.c	2023-07-27 15:03:24.245234299 +0200
@@ -0,0 +1,49 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-fsanitize=signed-integer-overflow,shift -fsanitize-recover=signed-integer-overflow,shift" } */
+
+__attribute__((noipa)) int
+foo (_BitInt(15) *p, _BitInt(15) *q, int n)
+{
+  q[0] = p[0] + p[1];
+  q[1] = p[2] - p[3];
+  q[2] = p[4] * p[5];
+  q[3] = p[6] / p[7];
+  q[4] = p[8] << n;
+  q[5] = p[9] >> n;
+  return n;
+}
+
+int
+main ()
+{
+  static _BitInt(15) p[] = {
+    16382wb, 1wb,
+    -16383wb, 1wb,
+    127wb, 129wb,
+    -16383wb - 1, 1wb,
+    0wb, 1wb,
+    16383wb, 1wb,
+    -16383wb - 1, 1wb,
+    127wb, 130wb,
+    -16383wb - 1, -1wb,
+    0wb, 1wb
+  };
+  _BitInt(15) q[6];
+  int n = foo (p, q, 14);
+  q[4] = p[8] << (n + 2);
+  q[5] = p[9] >> (n + 2);
+  foo (p + 10, q, 15);
+}
+
+/* The 16-bit type vs. 15-bit is small inaccuracy.  */
+/* { dg-output "shift exponent 16 is too large for 16-bit type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*shift exponent 16 is too large for 16-bit type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 16383 \\+ 1 cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: -16384 - 1 cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 127 \\* 130 cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*division of -16384 by -1 cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* This isn't accurate, but libubsan right now doesn't know it is 15-bit type rather than 16-bit.  */
+/* { dg-output "\[^\n\r]*left shift of 0 by 15 places cannot be represented in type '_BitInt\\\(15\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* The wording is totally incorrect, but at least it is diagnosed.  */
+/* { dg-output "\[^\n\r]*left shift of 1 by 15 places cannot be represented in type '_BitInt\\\(15\\\)'" } */
--- gcc/testsuite/gcc.dg/ubsan/bitint-2.c.jj	2023-07-27 15:03:24.244234312 +0200
+++ gcc/testsuite/gcc.dg/ubsan/bitint-2.c	2023-07-27 15:03:24.244234312 +0200
@@ -0,0 +1,49 @@ 
+/* PR c/102989 */
+/* { dg-do run { target { bitint128 && int128 } } } */
+/* { dg-options "-fsanitize=signed-integer-overflow,shift -fsanitize-recover=signed-integer-overflow,shift" } */
+
+__attribute__((noipa)) int
+foo (_BitInt(125) *p, _BitInt(125) *q, int n)
+{
+  q[0] = p[0] + p[1];
+  q[1] = p[2] - p[3];
+  q[2] = p[4] * p[5];
+  q[3] = p[6] / p[7];
+  q[4] = p[8] << n;
+  q[5] = p[9] >> n;
+  return n;
+}
+
+int
+main ()
+{
+  static _BitInt(125) p[] = {
+    21267647932558653966460912964485513214wb, 1wb,
+    -21267647932558653966460912964485513215wb, 1wb,
+    4611686018427387903wb, 4611686018427387905wb,
+    -21267647932558653966460912964485513215wb - 1, 1wb,
+    0wb, 1wb,
+    21267647932558653966460912964485513215wb, 1wb,
+    -21267647932558653966460912964485513215wb - 1, 1wb,
+    4611686018427387903wb, 4611686018427387906wb,
+    -21267647932558653966460912964485513215wb - 1, -1wb,
+    0wb, 1wb
+  };
+  _BitInt(125) q[6];
+  int n = foo (p, q, 123);
+  q[4] = p[8] << (n + 5);
+  q[5] = p[9] >> (n + 5);
+  foo (p + 10, q, 125);
+}
+
+/* The 128-bit type vs. 125-bit is small inaccuracy.  */
+/* { dg-output "shift exponent 128 is too large for 128-bit type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*shift exponent 128 is too large for 128-bit type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 0x0fffffffffffffffffffffffffffffff \\+ 1 cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 0xf0000000000000000000000000000000 - 1 cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: 4611686018427387903 \\* 4611686018427387906 cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*division of 0xf0000000000000000000000000000000 by -1 cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* This isn't accurate, but libubsan right now doesn't know it is 125-bit type rather than 128-bit.  */
+/* { dg-output "\[^\n\r]*left shift of 0 by 125 places cannot be represented in type '_BitInt\\\(125\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* The wording is totally incorrect, but at least it is diagnosed.  */
+/* { dg-output "\[^\n\r]*left shift of 1 by 125 places cannot be represented in type '_BitInt\\\(125\\\)'" } */
--- gcc/testsuite/gcc.dg/ubsan/bitint-3.c.jj	2023-07-27 15:03:24.244234312 +0200
+++ gcc/testsuite/gcc.dg/ubsan/bitint-3.c	2023-07-27 15:03:24.244234312 +0200
@@ -0,0 +1,45 @@ 
+/* PR c/102989 */
+/* { dg-do run { target bitint575 } } */
+/* { dg-options "-fsanitize=signed-integer-overflow,shift -fsanitize-recover=signed-integer-overflow,shift" } */
+
+__attribute__((noipa)) int
+foo (_BitInt(575) *p, _BitInt(575) *q, int n)
+{
+  q[0] = p[0] + p[1];
+  q[1] = p[2] - p[3];
+  q[2] = p[4] * p[5];
+  q[3] = p[6] / p[7];
+  q[4] = p[8] << n;
+  q[5] = p[9] >> n;
+  return n;
+}
+
+int
+main ()
+{
+  static _BitInt(575) p[] = {
+    61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174782wb, 1wb,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1wb,
+    248661618204893321077691124073410420050228075398673858720231988446579748506266687766527wb, 248661618204893321077691124073410420050228075398673858720231988446579748506266687766529wb,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 1wb,
+    0wb, 1wb,
+    61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb, 1wb,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, 1wb,
+    248661618204893321077691124073410420050228075398673858720231988446579748506266687766527wb, 248661618204893321077691124073410420050228075398673858720231988446579748506266687766530wb,
+    -61832600368276133515125630254911797508782837275302959978515764023224306276632966792579100265310761247399417856504034834837841258576687802491886538775473291979151693037174783wb - 1, -1wb,
+    0wb, 1wb
+  };
+  _BitInt(575) q[6];
+  foo (p, q, 574);
+  foo (p + 10, q, 575);
+}
+
+/* These print unsigned integer overflow even when it is signed.  */
+/* { dg-output "signed integer overflow: <unknown> \\+ <unknown> cannot be represented in type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: <unknown> - <unknown> cannot be represented in type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*signed integer overflow: <unknown> \\* <unknown> cannot be represented in type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* Inaccurate.  */
+/* { dg-output "\[^\n\r]*division by zero\[^\n\r]*(\n|\r\n|\r)" } */
+/* The wording is totally incorrect, but at least it is diagnosed.  */
+/* { dg-output "\[^\n\r]*shift exponent 575 is too large for \[0-9]*-bit type '_BitInt\\\(575\\\)'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*shift exponent 575 is too large for \[0-9]*-bit type '_BitInt\\\(575\\\)'" } */