diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /llvm/lib/Support/KnownBits.cpp | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
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; +} |