[PATCH] D122703: [AArch64][InstCombine] Fold MLOAD and zero extensions into MLOAD
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 29 22:09:37 PDT 2022
Allen created this revision.
Allen added reviewers: paulwalker-arm, david-arm, fhahn, craig.topper.
Herald added subscribers: StephenFan, hiraditya, kristof.beyls.
Herald added a project: All.
Allen requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Accord the discussion in D122281 <https://reviews.llvm.org/D122281>, we missing an ISD::AND combine for MLOAD.
This patch is intend to handle that, so we can circle back the type MVT::nxv2i32
https://reviews.llvm.org/D122703
Files:
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/sve-masked-ldst-zext.ll
Index: llvm/test/CodeGen/AArch64/sve-masked-ldst-zext.ll
===================================================================
--- llvm/test/CodeGen/AArch64/sve-masked-ldst-zext.ll
+++ llvm/test/CodeGen/AArch64/sve-masked-ldst-zext.ll
@@ -97,7 +97,7 @@
; CHECK-LABEL: masked_zload_2i16_2f64:
; CHECK: ld1h { z0.d }, p0/z, [x0]
; CHECK-NEXT: ptrue p0.d
-; CHECK-NEXT: ucvtf z0.d, p0/m, z0.s
+; CHECK-NEXT: ucvtf z0.d, p0/m, z0.d
; CHECK-NEXT: ret
%wide.load = call <vscale x 2 x i16> @llvm.masked.load.nxv2i16(<vscale x 2 x i16>* %in, i32 2, <vscale x 2 x i1> %mask, <vscale x 2 x i16> undef)
%zext = zext <vscale x 2 x i16> %wide.load to <vscale x 2 x i32>
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -1247,7 +1247,6 @@
setLoadExtAction(Op, MVT::nxv2i64, MVT::nxv2i16, Legal);
setLoadExtAction(Op, MVT::nxv2i64, MVT::nxv2i32, Legal);
setLoadExtAction(Op, MVT::nxv4i32, MVT::nxv4i8, Legal);
- setLoadExtAction(Op, MVT::nxv2i32, MVT::nxv2i16, Legal);
setLoadExtAction(Op, MVT::nxv4i32, MVT::nxv4i16, Legal);
setLoadExtAction(Op, MVT::nxv8i16, MVT::nxv8i8, Legal);
}
@@ -14405,6 +14404,30 @@
EVT MemVT;
+ // Zero/any extend of an MLOAD
+ if (const MaskedLoadSDNode *MLd = dyn_cast<MaskedLoadSDNode>(Src)) {
+ MemVT = MLd->getMemoryVT();
+ MVT::SimpleValueType Ty = MemVT.getSimpleVT().SimpleTy;
+ SDValue Dup = N->getOperand(1);
+ if (Dup.getOpcode() != AArch64ISD::DUP)
+ return SDValue();
+
+ SDLoc DL(N);
+ ConstantSDNode *C = dyn_cast<ConstantSDNode>(Dup->getOperand(0));
+ if (!C)
+ return SDValue();
+
+ uint64_t ExtVal = C->getZExtValue();
+
+ // If the mask is fully covered by the MLOAD, we don't need to push
+ // a new AND onto the operand
+ EVT EltTy = MemVT.getVectorElementType();
+ if ((ExtVal == 0xFF && EltTy == MVT::i8) ||
+ (ExtVal == 0xFFFF && EltTy == MVT::i16) ||
+ (ExtVal == 0xFFFFFFFF && EltTy == MVT::i32))
+ return Src;
+ }
+
// SVE load instructions perform an implicit zero-extend, which makes them
// perfect candidates for combining.
switch (Opc) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122703.419047.patch
Type: text/x-patch
Size: 2310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220330/47d9e217/attachment-0001.bin>
More information about the llvm-commits
mailing list