https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97317

--- Comment #3 from Andrew Macleod <amacleod at redhat dot com> ---
Created attachment 49331
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49331&action=edit
patch to calculate negative side properly

This is actually due to not handling a cast very well when the precision of the
RHS is only 1 greater than the precision of the LHS.

lhs = (cast) RHS

we calculate the value of RHS by treating LHS as an unsigned, and
1) adding in all the ranges of LHS as positive ranges
2) adding in all the LHS values  as negative values
3) filling in all the other ranges in RHS between those negative and positive
values.   ie, all the various upper bits in RHS can be on or off... 

THe code breaks down when the precision of the RHS is off by one. when
calculating those negative values in 3), there wasn't a expectation that the
sign bit *is* basically the entire range, so when it was trying to calculate
the range o fthose bits, it was trying to create a nonsensical  range.

This patch fixes that particular problem, but further examination shows we
arent producing ranges as good as we could.. so I will continue delving into
it.

Reply via email to