[PATCH] D134875: [AArch64] refactor Opcode selection for LowerMUL (NFC)
Zain Jaffal via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 29 06:35:42 PDT 2022
zjaffal created this revision.
zjaffal added a reviewer: fhahn.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
zjaffal requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Move the logic for selecting `NewOpc` out of `LowerMUL`
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134875
Files:
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -4371,6 +4371,40 @@
return DAG.getNode(ISD::INTRINSIC_VOID, DL, MVT::Other, Ops2);
}
+unsigned static selectUmullSmull(SDNode *&N0, SDNode *&N1, SelectionDAG &DAG,
+ SDLoc DL, bool &isMLA) {
+
+ bool isN0SExt = isSignExtended(N0, DAG);
+ bool isN1SExt = isSignExtended(N1, DAG);
+ if (isN0SExt && isN1SExt)
+ return AArch64ISD::SMULL;
+
+ bool isN0ZExt = isZeroExtended(N0, DAG);
+ bool isN1ZExt = isZeroExtended(N1, DAG);
+
+ if (isN0ZExt && isN1ZExt)
+ return AArch64ISD::UMULL;
+
+ if (!isN1SExt && !isN1ZExt)
+ return 0;
+ // Look for (s/zext A + s/zext B) * (s/zext C). We want to turn these
+ // into (s/zext A * s/zext C) + (s/zext B * s/zext C)
+ if (isN1SExt && isAddSubSExt(N0, DAG)) {
+ isMLA = true;
+ return AArch64ISD::SMULL;
+ }
+ if (isN1ZExt && isAddSubZExt(N0, DAG)) {
+ isMLA = true;
+ return AArch64ISD::UMULL;
+ }
+ if (isN0ZExt && isAddSubZExt(N1, DAG)) {
+ std::swap(N0, N1);
+ isMLA = true;
+ return AArch64ISD::UMULL;
+ }
+ return 0;
+}
+
SDValue AArch64TargetLowering::LowerMUL(SDValue Op, SelectionDAG &DAG) const {
EVT VT = Op.getValueType();
@@ -4386,32 +4420,9 @@
"unexpected type for custom-lowering ISD::MUL");
SDNode *N0 = Op.getOperand(0).getNode();
SDNode *N1 = Op.getOperand(1).getNode();
- unsigned NewOpc = 0;
+ SDLoc DL(Op);
bool isMLA = false;
- bool isN0SExt = isSignExtended(N0, DAG);
- bool isN1SExt = isSignExtended(N1, DAG);
- if (isN0SExt && isN1SExt)
- NewOpc = AArch64ISD::SMULL;
- else {
- bool isN0ZExt = isZeroExtended(N0, DAG);
- bool isN1ZExt = isZeroExtended(N1, DAG);
- if (isN0ZExt && isN1ZExt)
- NewOpc = AArch64ISD::UMULL;
- else if (isN1SExt || isN1ZExt) {
- // Look for (s/zext A + s/zext B) * (s/zext C). We want to turn these
- // into (s/zext A * s/zext C) + (s/zext B * s/zext C)
- if (isN1SExt && isAddSubSExt(N0, DAG)) {
- NewOpc = AArch64ISD::SMULL;
- isMLA = true;
- } else if (isN1ZExt && isAddSubZExt(N0, DAG)) {
- NewOpc = AArch64ISD::UMULL;
- isMLA = true;
- } else if (isN0ZExt && isAddSubZExt(N1, DAG)) {
- std::swap(N0, N1);
- NewOpc = AArch64ISD::UMULL;
- isMLA = true;
- }
- }
+ unsigned NewOpc = selectUmullSmull(N0, N1, DAG, DL, isMLA);
if (!NewOpc) {
if (VT == MVT::v2i64)
@@ -4420,11 +4431,9 @@
else
// Other vector multiplications are legal.
return Op;
- }
}
// Legalize to a S/UMULL instruction
- SDLoc DL(Op);
SDValue Op0;
SDValue Op1 = skipExtensionForVectorMULL(N1, DAG);
if (!isMLA) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134875.463870.patch
Type: text/x-patch
Size: 2882 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220929/1d036f88/attachment.bin>
More information about the llvm-commits
mailing list