[libcxx-commits] [libcxx] [Support] Add KnownBits::computeForSubBorrow (PR #67788)
Nikita Popov via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Oct 1 04:58:41 PDT 2023
================
@@ -3732,14 +3732,18 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
assert(Op.getResNo() == 0 &&
"We only compute knownbits for the difference here.");
- // TODO: Compute influence of the carry operand.
- if (Opcode == ISD::USUBO_CARRY || Opcode == ISD::SSUBO_CARRY)
- break;
+ // With UADDO_CARRY and SSUBO_CARRY a borrow bit may be added in.
+ KnownBits Borrow(1);
+ if (Opcode == ISD::USUBO_CARRY || Opcode == ISD::SSUBO_CARRY) {
+ Borrow = computeKnownBits(Op.getOperand(2), DemandedElts, Depth + 1);
+ // Borrow has bit width 1
+ Borrow = Borrow.zextOrTrunc(1);
----------------
nikic wrote:
There are no zero-bit integers in SDAG (or IR). The use of zextOrTrunc in the comment probably dates back to the time when APInt did not allow zext/sext/trunc to the original bit width.
https://github.com/llvm/llvm-project/pull/67788
More information about the libcxx-commits
mailing list