On 2 June 2013 15:36, Paolo Bonzini <pbonz...@redhat.com> wrote:
> This should work:
>
>     int64_t h;
>     if (!n) {
>         return a;
>     }
>     h = a.hi >> n;

This is undefined for n >= 64.

>     if (n >= 64) {
>         return (Int128) { h, h >> 63 };
>     } else {
>        return (Int128) { (a.lo >> n) | (a.hi << (64 - n)), h };
>     }

I would suggest looking at fpu/softfloat-macros.h:shift128Right()
except that that has at least one clearly dubious thing in it
(a check for "count < 64" in an else case that can't be reached
if count < 64)...

thanks
-- PMM

Reply via email to