[PATCH] D131491: [LoongArch] Override TargetLowering::isOffsetFoldingLegal()
Lu Weining via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 10 20:29:20 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc437412fbc1e: [LoongArch] Override TargetLowering::isOffsetFoldingLegal() (authored by wangleiat, committed by SixWeining).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131491/new/
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
@@ -64,6 +64,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
@@ -132,6 +132,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.451713.patch
Type: text/x-patch
Size: 2482 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220811/240b240b/attachment.bin>
More information about the llvm-commits
mailing list