[libc-commits] [libc] [Support] Add KnownBits::computeForSubBorrow (PR #67788)
via libc-commits
libc-commits at lists.llvm.org
Fri Sep 29 09:09:26 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);
+ } else
+ Borrow.setAllZero();
----------------
goldsteinn wrote:
nit: braces around else block if braces around if block.
https://github.com/llvm/llvm-project/pull/67788
More information about the libc-commits
mailing list