From 7671fc71f62a7387c06742c569fe17608796e8f2 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 12 Apr 2019 18:18:08 +0000 Subject: [KnownBits] Add computeForAddCarry() This is for D60460. computeForAddSub() essentially already supports carries because it has to deal with subtractions. This revision extracts a lower-level computeForAddCarry() function, which allows computing the known bits for add (carry known zero), sub (carry known one) and addcarry (carry unknown). As we don't seem to have any yet, I've added a unit test file for KnownBits and exhaustive tests for the new computeForAddCarry() functionality, as well the existing computeForAddSub() function. Differential Revision: https://reviews.llvm.org/D60522 llvm-svn: 358297 --- llvm/include/llvm/Support/KnownBits.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/include') diff --git a/llvm/include/llvm/Support/KnownBits.h b/llvm/include/llvm/Support/KnownBits.h index ed32cd2b576..07fd94e29a1 100644 --- a/llvm/include/llvm/Support/KnownBits.h +++ b/llvm/include/llvm/Support/KnownBits.h @@ -202,6 +202,10 @@ public: return getBitWidth() - Zero.countPopulation(); } + /// Compute known bits resulting from adding LHS, RHS and a 1-bit Carry. + static KnownBits computeForAddCarry( + const KnownBits &LHS, const KnownBits &RHS, const KnownBits &Carry); + /// Compute known bits resulting from adding LHS and RHS. static KnownBits computeForAddSub(bool Add, bool NSW, const KnownBits &LHS, KnownBits RHS); -- cgit v1.2.3