This patch resolves suboptimal code generation reported by https://github.com/llvm/llvm-project/issues/60571 .
DAGCombiner currently converts (x or/xor const) + y to (x + y) + const if this is valid.
However, if .. + const is broken down into a sequences of adds with carries, the benefit is not clear, introducing two more add(-with-carry) ops (total 6) in the case of the reported issue whereas the optimal sequence must only have 4 add(-with-carry)s.
This patch resolves this issue by allowing this conversion only when (1) .. + const is legal or promotable, or (2) const is a sign bit because it does not introduce more adds.
You might be able to do this as NoAddCarry = isMinSignedConstant(N0.getOperand(1));