[llvm] [DAGCombiner] Require a 0/1 carry-in when rebuilding a borrow chain (PR #223396)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 08:46:55 PDT 2026
topperc wrote:
> > Is it really true that UADDO_CARRY/USUBO_CARRY don't conform to getBooleanContents? Type legalization uses PromoteIntRes_Overflow which uses PromoteTargetBoolean and getBoolExtOrTrunc.
>
> You are right here, I got confused by doc "the third is a boolean value that is 1 if and only if there is an incoming carry/borrow".
>
> The fix works somehow: it is correct for ZeroOrOneBooleanContent, it is too restrictive for UndefinedBooleanContent and wrong for ZeroOrNegativeOneBooleanContent, but unreachable for the last case.
>
> The fix focus on matching side: is value "CarryIn" known to be valid target boolean. Should I add proper `isKnownTargetBoolean` helper? I was not able to find any.
>
> Alternative, is to mask CarryIn. I tried this path and it was causing issues as it sometimes adds new instruction. But I can revisit this path if you think this is worth it.
In the near term, for the backport can we just disable the combine for anything but ZeroOrOneBooleanContent? I doubt we have test coverage.
https://github.com/llvm/llvm-project/pull/223396
More information about the llvm-commits
mailing list