[flang-commits] [flang] [Support] Add KnownBits::computeForSubBorrow (PR #67788)
Shafik Yaghmour via flang-commits
flang-commits at lists.llvm.org
Sun Oct 1 19:15:05 PDT 2023
================
@@ -85,6 +85,18 @@ KnownBits KnownBits::computeForAddSub(bool Add, bool NSW,
return KnownOut;
}
+KnownBits KnownBits::computeForSubBorrow(const KnownBits &LHS, KnownBits RHS,
+ const KnownBits &Borrow) {
+ assert(Borrow.getBitWidth() == 1 && "Borrow must be 1-bit");
+
+ // LHS - RHS = LHS + ~RHS + 1
+ // Carry 1 - Borrow in ::computeForAddCarry
+ std::swap(RHS.Zero, RHS.One);
+ return ::computeForAddCarry(LHS, RHS,
+ /*CarryZero*/ Borrow.One.getBoolValue(),
+ /*CarryOne*/ Borrow.Zero.getBoolValue());
----------------
shafik wrote:
```suggestion
/*CarryZero=*/Borrow.One.getBoolValue(),
/*CarryOne=*/Borrow.Zero.getBoolValue());
```
https://github.com/llvm/llvm-project/pull/67788
More information about the flang-commits
mailing list