-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[AArch64] SimplifyDemandedBitsForTargetNode - add AArch64ISD::BICi handling #76644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+30
−4
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24555,6 +24555,18 @@ SDValue AArch64TargetLowering::PerformDAGCombine(SDNode *N, | |
if (auto R = foldOverflowCheck(N, DAG, /* IsAdd */ false)) | ||
return R; | ||
return performFlagSettingCombine(N, DCI, AArch64ISD::SBC); | ||
case AArch64ISD::BICi: { | ||
APInt DemandedBits = | ||
APInt::getAllOnes(N->getValueType(0).getScalarSizeInBits()); | ||
APInt DemandedElts = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would expect this not be all bits, but to only demand the bits that are not cleared by the BIC. Again this might be difficult to test though, so it might be best to leave it as-is for the moment. |
||
APInt::getAllOnes(N->getValueType(0).getVectorNumElements()); | ||
|
||
if (DAG.getTargetLoweringInfo().SimplifyDemandedBits( | ||
SDValue(N, 0), DemandedBits, DemandedElts, DCI)) | ||
return SDValue(); | ||
|
||
break; | ||
} | ||
case ISD::XOR: | ||
return performXorCombine(N, DAG, DCI, Subtarget); | ||
case ISD::MUL: | ||
|
@@ -27595,6 +27607,24 @@ bool AArch64TargetLowering::SimplifyDemandedBitsForTargetNode( | |
// used - simplify to just Val. | ||
return TLO.CombineTo(Op, ShiftR->getOperand(0)); | ||
} | ||
case AArch64ISD::BICi: { | ||
// Fold BICi if all destination bits already known to be zeroed | ||
SDValue Op0 = Op.getOperand(0); | ||
KnownBits KnownOp0 = | ||
TLO.DAG.computeKnownBits(Op0, OriginalDemandedElts, Depth + 1); | ||
// Op0 &= ~(ConstantOperandVal(1) << ConstantOperandVal(2)) | ||
uint64_t BitsToClear = Op->getConstantOperandVal(1) | ||
<< Op->getConstantOperandVal(2); | ||
APInt AlreadyZeroedBitsToClear = BitsToClear & KnownOp0.Zero; | ||
if (APInt(Known.getBitWidth(), BitsToClear) | ||
.isSubsetOf(AlreadyZeroedBitsToClear)) | ||
return TLO.CombineTo(Op, Op0); | ||
|
||
Known = KnownOp0 & | ||
KnownBits::makeConstant(APInt(Known.getBitWidth(), ~BitsToClear)); | ||
|
||
return false; | ||
} | ||
case ISD::INTRINSIC_WO_CHAIN: { | ||
if (auto ElementSize = IsSVECntIntrinsic(Op)) { | ||
unsigned MaxSVEVectorSizeInBits = Subtarget->getMaxSVEVectorSizeInBits(); | ||
|
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Known isn't used?