On Tue, Aug 27, 2013 at 5:47 PM, Mike Stump <mikest...@comcast.net> wrote: > On Aug 27, 2013, at 3:23 AM, Richard Biener <richard.guent...@gmail.com> > wrote: >>> +++ b/gcc/fold-const.c >>> @@ -3702,12 +3702,23 @@ all_ones_mask_p (const_tree mask, int size) > >> This should instead use >> >> return tree_to_double_int (mask) == double_int::mask (size) >> || (TYPE_PRECISION (mask) == size && tree_to_double_int >> (mask).all_onesp ()) >> >> and avoid all the tree building. > > Yeah, we tried that, but it didn't work out (regressions in the test suite). > We did this instead: > > /* If this function returns true when the type of the mask is > UNSIGNED, then there will be errors. In particular see > gcc.c-torture/execute/990326-1.c. There does not appear to be > any documentation paper trail as to why this is so. But the pre > wide-int worked with that restriction and it has been preserved > here. */ > if (size > precision || TYPE_SIGN (type) == UNSIGNED) > return false; > > in our code. We don't want to introduce bugs into the compiler in the > wide-int branch, so we opted to implement the original semantics and merely > note the oddity. > > The good news is our implementation is nice, short and sweet: > > return wide_int::mask (size, false, precision) == mask; > > once one gets past this special case. > > We'd love it if someone in the know can elaborate why unsigned needs to be > false, or alternatively, fix the compiler on trunk so that we can return true > with unsigned types. We didn't spot the reason.
Digging shows I at one point removed all this code - but people objected and I had to revert it :/ I suppose this kind of cleanup should be done on trunk, without introducing wide-int first. Note that rejecting all unsigned masks doesn't make much sense to me, so it must be some special-case in the caller that is wrong. Richard.