]> git.ipfire.org Git - thirdparty/gcc.git/commit
wide-int: Fix up set_bit_large
authorJakub Jelinek <jakub@redhat.com>
Wed, 28 Oct 2020 09:24:20 +0000 (10:24 +0100)
committerJakub Jelinek <jakub@redhat.com>
Mon, 2 Nov 2020 12:01:11 +0000 (13:01 +0100)
commite41011e5edcd9606573d3450d98512450dddca77
tree889d2efd976b8026570f252c731c34e89e593669
parent5ab7959ee18980d676892fa6579f1ca09c5ecc08
wide-int: Fix up set_bit_large

> >> wide_int new_lb = wi::set_bit (r.lower_bound (0), 127)
> >>
> >> and creates the value:
> >>
> >> p new_lb
> >> {<wide_int_storage> = {val = {-65535, -1, 0}, len = 2, precision = 128},
> >> static is_sign_extended = true}
> >
> > This is non-canonical and so invalid, if the low HWI has the MSB set
> > and the high HWI is -1, it should have been just
> > val = {-65535}, len = 1, precision = 128}
> >
> > I guess the bug is that wi::set_bit_large doesn't call canonize.
>
> Yeah, looks like a micro-optimisation gone wrong.

2020-10-28  Jakub Jelinek  <jakub@redhat.com>

* wide-int.cc (wi::set_bit_large): Call canonize unless setting
msb bit and clearing bits above it.
gcc/wide-int.cc