Richard Biener <richard.guent...@gmail.com> writes: > On August 4, 2015 4:28:26 PM GMT+02:00, Richard Sandiford > <richard.sandif...@arm.com> wrote: >>Richard Biener <richard.guent...@gmail.com> writes: >>> On Tue, Aug 4, 2015 at 4:21 PM, Richard Biener >>> <richard.guent...@gmail.com> wrote: >>>> On Tue, Aug 4, 2015 at 4:15 PM, Richard Sandiford >>>> <richard.sandif...@arm.com> wrote: >>>>> Richard Biener <richard.guent...@gmail.com> writes: >>>>>> in fact the first if () looks redundant if you simply put an else >>>>>> return NULL >>>>>> after a else if (wi::exact_log2 (wi::neg (oprnd1)) != -1) >>>>>> >>>>>> Note that the issue with INT_MIN is that wi::neg (INT_MIN) is >>INT_MIN >>>>>> again, but it seems that wi::exact_log2 returns -1 in that case so >>you >>>>>> are fine (and in fact not handling this case). >>>>> >>>>> Are you sure it returns -1 for INT_MIN? It isn't supposed to, >>assuming >>>>> INT_MIN is shorthand for "minimum value for a signed type". >>wide_ints >>>>> aren't signed, so INT_MIN is indistinguishable from an unsigned >>>>> 1<<(prec-1). >>>> >>>> No, not sure. I spotted >>>> >>>> /* Reject cases where there are implicit -1 blocks above HIGH. */ >>>> if (x.len * HOST_BITS_PER_WIDE_INT < x.precision && x.sign_mask () >>< 0) >>>> return -1; >>>> >>>> and thought that would catch it. I mean the tree value is negative >>so >>>> exact_log2 must see it is a negative value. >> >>That's handling the "compressed" format, e.g.: >> >> {1 << 63} >> >>as a 64-bit short-hand for a 256-bit: >> >> {1 << 63,-1,-1,-1} >> >>In this case more than one of the low x.precision bits are known to be >>set. > > So you are saying exact_log2 is really exact_log2u?
Not sure what you mean, sorry. All I meant was that a number like: 0xffffffff_ffffffff_ffffffff_80000000 (uing 32-bit rather than 64-bit elements for brevity) is stored as a single {0x80000000}, with the upper 3 elements being implicit. And: exact_log2 (0xffffffff_ffffffff_ffffffff_80000000) is obviously -1. That's the case that the code above is handling. If there are implicit all-1 blocks, the number is not a power of 2. Thanks, Richard