[PATCH] D131491: [LoongArch] Override TargetLowering::isOffsetFoldingLegal()
Ray Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 9 06:06:37 PDT 2022
wangleiat created this revision.
wangleiat added reviewers: MaskRay, xen0n, SixWeining, xry111, gonglingqin.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
wangleiat requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch disable GlobalAddress+Offset folding.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131491
Files:
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
llvm/lib/Target/LoongArch/LoongArchISelLowering.h
llvm/test/CodeGen/LoongArch/ir-instruction/load-store.ll
Index: llvm/test/CodeGen/LoongArch/ir-instruction/load-store.ll
===================================================================
--- llvm/test/CodeGen/LoongArch/ir-instruction/load-store.ll
+++ llvm/test/CodeGen/LoongArch/ir-instruction/load-store.ll
@@ -45,8 +45,8 @@
; LA32PIC-NEXT: addi.w $a2, $a1, .Larr$local
; LA32-NEXT: ld.w $a1, $a2, 0
; LA32-NEXT: st.w $a0, $a2, 0
-; LA32NOPIC-NEXT: ld.w $a3, $a2, 0
-; LA32NOPIC-NEXT: st.w $a0, $a2, 0
+; LA32NOPIC-NEXT: ld.w $a3, $a2, 36
+; LA32NOPIC-NEXT: st.w $a0, $a2, 36
; LA32PIC-NEXT: ld.w $a3, $a2, 36
; LA32PIC-NEXT: st.w $a0, $a2, 36
@@ -56,8 +56,8 @@
; LA64PIC-NEXT: addi.d $a2, $a1, .Larr$local
; LA64-NEXT: ld.w $a1, $a2, 0
; LA64-NEXT: st.w $a0, $a2, 0
-; LA64NOPIC-NEXT: ld.w $a3, $a2, 0
-; LA64NOPIC-NEXT: st.w $a0, $a2, 0
+; LA64NOPIC-NEXT: ld.w $a3, $a2, 36
+; LA64NOPIC-NEXT: st.w $a0, $a2, 36
; LA64PIC-NEXT: ld.w $a3, $a2, 36
; LA64PIC-NEXT: st.w $a0, $a2, 36
Index: llvm/lib/Target/LoongArch/LoongArchISelLowering.h
===================================================================
--- llvm/lib/Target/LoongArch/LoongArchISelLowering.h
+++ llvm/lib/Target/LoongArch/LoongArchISelLowering.h
@@ -62,6 +62,8 @@
const LoongArchSubtarget &getSubtarget() const { return Subtarget; }
+ bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
+
// Provide custom lowering hooks for some operations.
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
Index: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
===================================================================
--- llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -122,6 +122,15 @@
setTargetDAGCombine(ISD::SRL);
}
+bool LoongArchTargetLowering::isOffsetFoldingLegal(
+ const GlobalAddressSDNode *GA) const {
+ // In order to maximise the opportunity for common subexpression elimination,
+ // keep a separate ADD node for the global address offset instead of folding
+ // it in the global address node. Later peephole optimisations may choose to
+ // fold it back in when profitable.
+ return false;
+}
+
SDValue LoongArchTargetLowering::LowerOperation(SDValue Op,
SelectionDAG &DAG) const {
switch (Op.getOpcode()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131491.451129.patch
Type: text/x-patch
Size: 2482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220809/3bf7461b/attachment-0001.bin>
More information about the llvm-commits
mailing list