https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102134
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Jakub Jelinek from comment #3) > This is triggering the: > else if (!wi::neg_p (r1val | r1mask, sgn)) > { > /* Logical right shift, or zero sign bit. */ > widest_int arg = r1val | r1mask; > int lzcount = wi::clz (arg); > lzcount -= wi::get_precision (arg) - width; > widest_int tmp = wi::mask <widest_int> (width, false); > tmp = wi::lrshift (tmp, lzcount); > tmp = wi::lrshift (tmp, wi::bit_and_not (r2val, r2mask)); > *mask = wi::ext (tmp, width, sgn); > *val = 0; > } > sgn is UNSIGNED, so wi::neg_p is false even when r1val | r1mask is negative, > so > wi::clz (arg) is 0, but wi::get_precision (arg) is 576 and width is 64, so > we end up with lzcount of -512 and I bet the code doesn't expect lzcount to > be negative. So perhaps either guard the subtraction on if (lzcount) lzcount -= wi::get_precision (arg) - width; - when lzcount is 0, the sign bit is set and we shouldn't shift it right, or do int lzcount; if (wi::neg_p (arg)) lzcount = 0; else lzcount = wi::clz (arg) - (wi::get_precision (arg) - width);