https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104334
--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> --- > And another question is, the 2, 3, 4 cases handling seems like an > optimization, > so wi_fold at line 192 should give the right answer, but it > doesn't. Actually no, I misunderstood, with -O0 or non-LTO, it is the wi_fold call, while with LTO it is the 178 wi_fold (r, type, lh_lb, lh_lb, rh_lb, rh_ub); 179 if (wi::gt_p (lh_range, 1, sign)) 180 { 181 wi_fold (tmp, type, lh_lb + 1, lh_lb + 1, rh_lb, rh_ub); 182 r.union_ (tmp); 183 if (wi::eq_p (lh_range, 3)) 184 { (gdb) 185 wi_fold (tmp, type, lh_lb + 2, lh_lb + 2, rh_lb, rh_ub); 186 r.union_ (tmp); 187 } 188 } 189 wi_fold (tmp, type, lh_ub, lh_ub, rh_lb, rh_ub); 190 r.union_ (tmp); optimization. And that one doesn't work too well, because wi::eq_p (lh_range, 3) is false: xi.is_sign_extended is true, yi.is_sign_extended is true lh_range.val[0] is -1, and yi.val[0] is 3, so it isn't equal. That is because we haven't sign-extended 3.