On Tue, Nov 8, 2016 at 1:03 PM, Kyrill Tkachov <kyrylo.tkac...@foss.arm.com> wrote: > Hi all, > > There is an off-by-one error in the clear_bit_region helper in store merging > in the case where it deals with > multi-byte quantities starting at a non-zero bit offset. The particular > input is > {0xff, 0xff, 0xff} and we want to clear all bits except the least and most > significant i.e. we want: > {0x01, 0x00, 0x80} so it's called as clear_bit_region (input, 1, 22); > This ends up clearing one more bit due to this bug. The patch fixes that. > The last argument to clear_bit_region is the number of bits left to clear > and since in the previous call we cleared > BITS_PER_UNIT - start bits we should subtract exactly that amount from len > when calculating the bits left to clear. > This was uncovered when writing initial unit tests for these functions which > are included in the followup patch. > > Bootstrapped and tested on aarch64 and x86_64 (the affected function is only > called for little-endian code). > > Ok for trunk?
Ok. Richard. > Thanks, > Kyrill > > 2016-11-08 Kyrylo Tkachov <kyrylo.tkac...@arm.com> > > PR tree-optimization/78234 > * gimple-ssa-store-merging.c (clear_bit_region): Fix off-by-one error > in start != 0 case.