llvm::isKnownToBeAPowerOfTwo

Test if the given value is known to have exactly one bit set.

Synopsis

Declared in <llvm/CodeGen/GlobalISel/Utils.h>

bool
isKnownToBeAPowerOfTwo(
    Register Val,
    MachineRegisterInfo const& MRI,
    GISelValueTracking* ValueTracking = nullptr,
    bool OrNegative = false);

Description

This differs from computeKnownBits in that it doesn't necessarily determine which bit is set. When OrNegative is true, the value is also considered a power of two if its negation is a power of two (i.e. its absolute value is a power of two).

Return Value

True if Val is known to be a power of two.

Parameters

NameDescription
ValRegister whose value is tested.
MRIRegister information for the function.
ValueTrackingOptional value-tracking analysis to consult.
OrNegativeAlso accept values whose negation is a power of two.