Repository navigation
[DAGCombiner] Restrict combineOrOfSetCCToUSUBOCarry to ZeroOrOneBooleanContent. - #224759
Merged
Merged
Conversation
…anContent. We need to ensure the carry in matches boolean contents. We are checking MaskedValueIsZero which is only valid for ZeroOrOneBooleanContent. We could check ComputeNumSignBits for ZeroOrNegativeOneBooleanContent, but no in tree target supports USUBO_CARRY and ZeroOrNegativeOneBooleanContent.
|
@llvm/pr-subscribers-llvm-selectiondag Author: Craig Topper (topperc) ChangesWe need to ensure the carry in matches boolean contents. We are checking MaskedValueIsZero which is only valid for ZeroOrOneBooleanContent. We could check ComputeNumSignBits for ZeroOrNegativeOneBooleanContent, but no in tree target supports USUBO_CARRY and ZeroOrNegativeOneBooleanContent. This was an oversight in #223396 due to incorrect documentation for USUBO_CARRY. I will fix that in a separate patch. 1 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index a9485e336837e..59d6cc7652510 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3972,9 +3972,11 @@ static SDValue combineOrOfSetCCToUSUBOCarry(SDNode *N, SelectionDAG &DAG,
*DAG.getContext(), IntVT)))
return SDValue();
- // USUBO_CARRY's carry-in must be 0 or 1, which the matched pattern does not
- // guarantee.
- if (!DAG.MaskedValueIsZero(
+ // USUBO_CARRY's carry-in must match boolean contents, which the matched
+ // pattern does not guarantee.
+ if (TLI.getBooleanContents(IntVT) !=
+ TargetLowering::ZeroOrOneBooleanContent ||
+ !DAG.MaskedValueIsZero(
CarryIn,
APInt::getBitsSetFrom(CarryIn.getScalarValueSizeInBits(), 1)))
return SDValue();
|
chfast
approved these changes
Sep 18, 2026
| // guarantee. | ||
| if (!DAG.MaskedValueIsZero( | ||
| // USUBO_CARRY's carry-in must match boolean contents, which the matched | ||
| // pattern does not guarantee. |
Member
There was a problem hiding this comment.
May add additional TODO to extent this to all bool constants variants.
Member
|
Failed to cherry-pick: 51d2905 Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request |
tru
pushed a commit
that referenced
this pull request
Sep 23, 2026
…anContent. (#224759) We need to ensure the carry in matches boolean contents. We are checking MaskedValueIsZero which is only valid for ZeroOrOneBooleanContent. We could check ComputeNumSignBits for ZeroOrNegativeOneBooleanContent, but no in tree target supports USUBO_CARRY and ZeroOrNegativeOneBooleanContent. This was an oversight in #223396 due to incorrect documentation for USUBO_CARRY. I will fix that in a separate patch. (cherry picked from commit 51d2905)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We need to ensure the carry in matches boolean contents. We are checking MaskedValueIsZero which is only valid for ZeroOrOneBooleanContent.
We could check ComputeNumSignBits for ZeroOrNegativeOneBooleanContent, but no in tree target supports USUBO_CARRY and ZeroOrNegativeOneBooleanContent.
This was an oversight in #223396 due to incorrect documentation for USUBO_CARRY. I will fix that in a separate patch.