-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AArch64] Add SimplifyDemandedVectorEltsForTargetNode support for AArch64ISD::DUPLANE nodes #167177
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
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-backend-aarch64 Author: None (Red-RobinHood) ChangesFull diff: https://github.com/llvm/llvm-project/pull/167177.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index c8a038fa99b30..7604cdc786268 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -31527,6 +31527,38 @@ bool AArch64TargetLowering::SimplifyDemandedBitsForTargetNode(
Op, OriginalDemandedBits, OriginalDemandedElts, Known, TLO, Depth);
}
+bool AArch64TargetLowering::SimplifyDemandedVectorEltsForTargetNode(
+ SDValue Op,
+ const APInt &DemandedElts,
+ APInt &KnownUndef,
+ APInt &KnownZero,
+ TargetLoweringOpt &TLO,
+ unsigned Depth) const {
+
+ SDNode *N = Op.getNode();
+ unsigned Opc = N->getOpcode();
+
+ if (Opc != AArch64ISD::DUPLANE8 &&
+ Opc != AArch64ISD::DUPLANE16 &&
+ Opc != AArch64ISD::DUPLANE32 &&
+ Opc != AArch64ISD::DUPLANE64)
+ return false;
+
+ if (DemandedElts.popcount() != 1)
+ return false;
+
+ SDValue Src = N->getOperand(0);
+ SDValue Lane = N->getOperand(1);
+
+ SDLoc DL(N);
+ SelectionDAG &DAG = TLO.DAG;
+
+ SDValue Extracted = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, Src.getValueType().getScalarType(), Src, Lane);
+ SDValue Splat = DAG.getSplatVector(Op.getValueType(), DL, Extracted);
+
+ return TLO.CombineTo(Op, Splat);
+}
+
bool AArch64TargetLowering::canCreateUndefOrPoisonForTargetNode(
SDValue Op, const APInt &DemandedElts, const SelectionDAG &DAG,
bool PoisonOnly, bool ConsiderFlags, unsigned Depth) const {
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
index 70bfae717fb76..6cd26fe871a60 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -880,6 +880,13 @@ class AArch64TargetLowering : public TargetLowering {
TargetLoweringOpt &TLO,
unsigned Depth) const override;
+ bool SimplifyDemandedVectorEltsForTargetNode(SDValue Op,
+ const APInt &DemandedElts,
+ APInt &KnownUndef,
+ APInt &KnownZero,
+ TargetLoweringOpt &TLO,
+ unsigned Depth) const override;
+
bool canCreateUndefOrPoisonForTargetNode(SDValue Op,
const APInt &DemandedElts,
const SelectionDAG &DAG,
|
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.h --diff_from_common_commit
View the diff from clang-format here.diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 7604cdc78..b0bdc6b9a 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -31528,32 +31528,28 @@ bool AArch64TargetLowering::SimplifyDemandedBitsForTargetNode(
}
bool AArch64TargetLowering::SimplifyDemandedVectorEltsForTargetNode(
- SDValue Op,
- const APInt &DemandedElts,
- APInt &KnownUndef,
- APInt &KnownZero,
- TargetLoweringOpt &TLO,
- unsigned Depth) const {
+ SDValue Op, const APInt &DemandedElts, APInt &KnownUndef, APInt &KnownZero,
+ TargetLoweringOpt &TLO, unsigned Depth) const {
SDNode *N = Op.getNode();
unsigned Opc = N->getOpcode();
- if (Opc != AArch64ISD::DUPLANE8 &&
- Opc != AArch64ISD::DUPLANE16 &&
- Opc != AArch64ISD::DUPLANE32 &&
- Opc != AArch64ISD::DUPLANE64)
+ if (Opc != AArch64ISD::DUPLANE8 && Opc != AArch64ISD::DUPLANE16 &&
+ Opc != AArch64ISD::DUPLANE32 && Opc != AArch64ISD::DUPLANE64)
return false;
if (DemandedElts.popcount() != 1)
- return false;
+ return false;
- SDValue Src = N->getOperand(0);
+ SDValue Src = N->getOperand(0);
SDValue Lane = N->getOperand(1);
SDLoc DL(N);
SelectionDAG &DAG = TLO.DAG;
- SDValue Extracted = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL, Src.getValueType().getScalarType(), Src, Lane);
+ SDValue Extracted =
+ DAG.getNode(ISD::EXTRACT_VECTOR_ELT, DL,
+ Src.getValueType().getScalarType(), Src, Lane);
SDValue Splat = DAG.getSplatVector(Op.getValueType(), DL, Extracted);
return TLO.CombineTo(Op, Splat);
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
index 6cd26fe87..ee6863528 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -880,12 +880,9 @@ private:
TargetLoweringOpt &TLO,
unsigned Depth) const override;
- bool SimplifyDemandedVectorEltsForTargetNode(SDValue Op,
- const APInt &DemandedElts,
- APInt &KnownUndef,
- APInt &KnownZero,
- TargetLoweringOpt &TLO,
- unsigned Depth) const override;
+ bool SimplifyDemandedVectorEltsForTargetNode(
+ SDValue Op, const APInt &DemandedElts, APInt &KnownUndef,
+ APInt &KnownZero, TargetLoweringOpt &TLO, unsigned Depth) const override;
bool canCreateUndefOrPoisonForTargetNode(SDValue Op,
const APInt &DemandedElts,
|
| bool AArch64TargetLowering::SimplifyDemandedVectorEltsForTargetNode( | ||
| SDValue Op, | ||
| const APInt &DemandedElts, |
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.
This needs formatting (with clang-format) and some tests
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.
Am I bit overwhelmed right now with some work. Will see to it in about a week.
Fixes #87497