[PATCH] D137844: [DAG] Fold zext/sext into masked loads with multiple truncate uses
Benjamin Maxwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 11 09:04:21 PST 2022
benmxwl-arm updated this revision to Diff 474786.
benmxwl-arm added a comment.
Remove accidentally committed file
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137844/new/
https://reviews.llvm.org/D137844
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/sve-load-compare-store.ll
Index: llvm/test/CodeGen/AArch64/sve-load-compare-store.ll
===================================================================
--- llvm/test/CodeGen/AArch64/sve-load-compare-store.ll
+++ llvm/test/CodeGen/AArch64/sve-load-compare-store.ll
@@ -6,9 +6,7 @@
; CHECK: // %bb.0: // %entry
; CHECK-NEXT: ptrue p0.b
; CHECK-NEXT: ld1h { z0.s }, p0/z, [x0]
-; CHECK-NEXT: mov z1.d, z0.d
-; CHECK-NEXT: and z1.s, z1.s, #0xffff
-; CHECK-NEXT: cmphs p0.s, p0/z, z1.s, #0
+; CHECK-NEXT: cmphs p0.s, p0/z, z0.s, #0
; CHECK-NEXT: st1b { z0.s }, p0, [x1]
; CHECK-NEXT: ret
entry:
Index: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -12097,13 +12097,29 @@
SDNode *N, SDValue N0,
ISD::LoadExtType ExtLoadType,
ISD::NodeType ExtOpc) {
- if (!N0.hasOneUse())
- return SDValue();
MaskedLoadSDNode *Ld = dyn_cast<MaskedLoadSDNode>(N0);
if (!Ld || Ld->getExtensionType() != ISD::NON_EXTLOAD)
return SDValue();
+ auto AllUsesCanBeReplaced = [&](SDValue V) {
+ for (SDNode::use_iterator UI = V->use_begin(), UE = V->use_end(); UI != UE;
+ ++UI) {
+ SDNode *User = *UI;
+ // Skip chain uses and the extension dag node N
+ if (UI.getUse().getResNo() != 0 || User == N)
+ continue;
+ // If all other uses of the load are just truncates we're fine to just
+ // truncate the extended type.
+ if (User->getOpcode() != ISD::TRUNCATE)
+ return false;
+ }
+ return true;
+ };
+
+ if (!AllUsesCanBeReplaced(N0))
+ return SDValue();
+
if (!TLI.isLoadExtLegalOrCustom(ExtLoadType, VT, Ld->getValueType(0)))
return SDValue();
@@ -12630,9 +12646,8 @@
ISD::ZEXTLOAD, ISD::ZERO_EXTEND))
return foldedExt;
- if (SDValue foldedExt =
- tryToFoldExtOfMaskedLoad(DAG, TLI, VT, N, N0, ISD::ZEXTLOAD,
- ISD::ZERO_EXTEND))
+ if (SDValue foldedExt = tryToFoldExtOfMaskedLoad(
+ DAG, TLI, VT, N, N0, ISD::ZEXTLOAD, ISD::ZERO_EXTEND))
return foldedExt;
// fold (zext (load x)) to multiple smaller zextloads.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137844.474786.patch
Type: text/x-patch
Size: 2377 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221111/691a3008/attachment.bin>
More information about the llvm-commits
mailing list