On Wed, Jul 30, 2025 at 10:17:43AM +0200, Jakub Jelinek wrote:
> On Wed, Jul 30, 2025 at 10:16:06AM +0200, Jakub Jelinek wrote:
> > Or maybe better
> >   _BitInt(PROMOTED_SIZE (x) * __CHAR_BIT__) __x;
> >   int __y = S (x);
> >   do_copy (&__x, &(x), sizeof (__x));
> >   if (__y < PROMOTED_SIZE (x) * __CHAR_BIT__)
> >     {
> >       int __neg = __x < 0;
> >       __x >>= PROMOTED_SIZE (x) * __CHAR_BIT__ - __y;
> 
> Obviously __x >>= __y;
> We want to shift away all the normal bits and keep just the padding bits
> which aren't padding in the promoted type.
> 
> >       if (__x != (__neg ? (typeof (__x)) -1 : (__typeof (__x)) 0))
> >     __builtin_abort ();

Or for the signed case instead of the __neg etc. games
shift right by __y - 1 instead of __y and abort if __x is neither 0 nor -1.

        Jakub

Reply via email to