diff options
Diffstat (limited to 'llvm/lib/Support/KnownBits.cpp')
-rw-r--r-- | llvm/lib/Support/KnownBits.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/Support/KnownBits.cpp b/llvm/lib/Support/KnownBits.cpp index 8f3f4aa8caeaf..1ff66d504cbea 100644 --- a/llvm/lib/Support/KnownBits.cpp +++ b/llvm/lib/Support/KnownBits.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/KnownBits.h" +#include <cassert> using namespace llvm; @@ -81,3 +82,28 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW, return KnownOut; } + +KnownBits &KnownBits::operator&=(const KnownBits &RHS) { + // Result bit is 0 if either operand bit is 0. + Zero |= RHS.Zero; + // Result bit is 1 if both operand bits are 1. + One &= RHS.One; + return *this; +} + +KnownBits &KnownBits::operator|=(const KnownBits &RHS) { + // Result bit is 0 if both operand bits are 0. + Zero &= RHS.Zero; + // Result bit is 1 if either operand bit is 1. + One |= RHS.One; + return *this; +} + +KnownBits &KnownBits::operator^=(const KnownBits &RHS) { + // Result bit is 0 if both operand bits are 0 or both are 1. + APInt Z = (Zero & RHS.Zero) | (One & RHS.One); + // Result bit is 1 if one operand bit is 0 and the other is 1. + One = (Zero & RHS.One) | (One & RHS.Zero); + Zero = std::move(Z); + return *this; +} |