value range propagation for _bitwise_ OR
Rainer Deyke
rainerd at eldwood.com
Sun Apr 11 22:11:37 PDT 2010
On 4/11/2010 20:51, Steven Schveighoffer wrote:
> Range propagation is needed to determine if you can put a value into a
> smaller type. At that point, all that is needed is the min and max.
Technically, you don't even need min and max at that point. A bit mask
would be enough.
> However, you are correct that without more data, the compiler might
> reject legitimate implicit casts that are easily proven.
>
> Would (min, max, mask) be enough to allow this? Or do we need an exact
> list...
I was think about two masks (min_mask and max_mask) such that
'(min_mask & x) == min_mask' and '(max_mask | x) == max_mask'. In other
words, 'min_mask' contains the bits that are definitely 1 in 'x' while
'max_mask' contains the bits that /could/ be 1 in 'x'. This avoids loss
of information in the presence of the bitwise inverse operator (unary '~').
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list