On Sun, Oct 11, 2015 at 4:56 AM, Kugan <kugan.vivekanandara...@linaro.org> wrote: > > > On 09/10/15 21:29, Richard Biener wrote: >> + unsigned int prec = tree_to_uhwi (vr1.min); >> >> this should use unsigned HOST_WIDE_INT >> >> + wide_int sign_bit = wi::shwi (1ULL << (prec - 1), >> + TYPE_PRECISION (TREE_TYPE (vr0.min))); >> >> use wi::one (TYPE_PRECISION (TREE_TYPE (vr0.min))) << (prec - 1); >> >> That is, you really need to handle precisions bigger than HOST_WIDE_INT. >> >> But I suppose wide_int really misses a test_bit function (it has a set_bit >> one already). >> >> + if (wi::bit_and (must_be_nonzero, sign_bit) == sign_bit) >> + { >> + /* If to-be-extended sign bit is one. */ >> + tmin = type_min; >> + tmax = may_be_nonzero; >> >> I think tmax should be zero-extended may_be_nonzero from prec. >> >> + else if (wi::bit_and (may_be_nonzero, sign_bit) >> + != sign_bit) >> + { >> + /* If to-be-extended sign bit is zero. */ >> + tmin = must_be_nonzero; >> + tmax = may_be_nonzero; >> >> likewise here tmin/tmax should be zero-extended may/must_be_nonzero from >> prec. >> >> + case SEXT_EXPR: >> + { >> + unsigned int prec = tree_to_uhwi (op1); >> + wide_int sign_bit = wi::shwi (1ULL << (prec - 1), >> + TYPE_PRECISION (TREE_TYPE >> (vr0.min))); >> + wide_int mask = wi::shwi (((1ULL << (prec - 1)) - 1), >> + TYPE_PRECISION (TREE_TYPE (vr0.max))); >> >> this has the same host precision issues of 1ULL (HOST_WIDE_INT). >> There is wi::mask, eventually you can use wi::set_bit_in_zero to >> produce the sign-bit wide_int (also above). > > > Thanks Ricahrd. Does the attached patch looks better ?
Yes. That variant is ok once prerequesites have been approved. Thanks, Richard. > Thanks, > Kugan