[PATCH] ValueTracking: Teach isKnownToBeAPowerOfTwo that a power-of-two-or-zero + the same power-of-two-or-zero is a power-of-two-or-zero
David Majnemer
david.majnemer at gmail.com
Tue Jul 30 14:03:44 PDT 2013
Committed in r187445.
On Mon, Jul 29, 2013 at 4:20 AM, Jay Foad <jay.foad at gmail.com> wrote:
> On 13 July 2013 23:21, David Majnemer <david.majnemer at gmail.com> wrote:
> > On Sat, Jul 13, 2013 at 12:03 PM, Nick Lewycky <nicholas at mxc.ca> wrote:
> >>
> >> David Majnemer wrote:
> >>>
> >>> Attached is a patch to strengthen isKnownToBeAPowerOfTwo's analysis on
> >>> add instructions.
> >>>
> >>> It calls into ComputeMaskedBits to figure out which bits are set on
> both
> >>> add operands and determines if the value is a power-of-two-or-zero or
> >>> not.
>
> The logic looks OK to me.
>
> I think you could relax this condition this a tiny bit:
>
> + APInt ComplementLHSZeroBits = ~LHSZeroBits;
> + if (ComplementLHSZeroBits == ~RHSZeroBits &&
> + ComplementLHSZeroBits.isPowerOf2()) {
>
> to:
>
> if ((~(LHSZeroBits & RHSZeroBits)).isPowerOf2())
>
> but that's mostly a matter of taste. (It would be nice if there was an
> APInt::isPowerOf2OrZero.)
>
> Jay.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130730/0ef35c5a/attachment.html>
More information about the llvm-commits
mailing list