[PATCH] D101470: [XCOFF][AIX] Peephole optimization in TocData transformation
Sidharth Baveja via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 29 14:22:08 PDT 2021
sidbav updated this revision to Diff 341640.
sidbav added a comment.
Address Review comments
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101470/new/
https://reviews.llvm.org/D101470
Files:
llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
llvm/test/CodeGen/PowerPC/toc-data.ll
Index: llvm/test/CodeGen/PowerPC/toc-data.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/toc-data.ll
+++ llvm/test/CodeGen/PowerPC/toc-data.ll
@@ -14,12 +14,11 @@
ret void
}
; CHECK: name: write_int
-; CHECK: %[[SCRATCH:[0-9]+]]:gprc_and_gprc_nor0 = ADDItoc @i, $r2
-; CHECK-NEXT: STW %{{[0-9]+}}, 0, killed %[[SCRATCH]] :: (store 4 into @i)
+; CHECK: %[[SCRATCH:[0-9]+]]:gprc = COPY $r3
+; CHECK-NEXT: STW %{{[0-9]+}}, @i, $r2 :: (store 4 into @i)
; TEST: .write_int:
-; TEST: la 4, i[TD](2)
-; TEST-NEXT: stw 3, 0(4)
+; TEST: stw 3, i[TD](2)
define dso_local i64 @read_ll() {
entry:
@@ -40,12 +39,10 @@
ret float %0
}
; CHECK: name: read_float
-; CHECK: %[[SCRATCH:[0-9]+]]:gprc_and_gprc_nor0 = ADDItoc @f, $r2
-; CHECK: %{{[0-9]+}}:f4rc = LFS 0, killed %[[SCRATCH]] :: (dereferenceable load 4 from @f)
+; CHECK: %{{[0-9]+}}:f4rc = LFS @f, $r2 :: (dereferenceable load 4 from @f)
; TEST: .read_float:
-; TEST: la 3, f[TD](2)
-; TEST-NEXT: lfs 1, 0(3)
+; TEST: lfs 1, f[TD](2)
define dso_local void @write_double(double %in) {
entry:
Index: llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
+++ llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
@@ -42,6 +42,11 @@
Mangler::getNameWithPrefix(Name, MO.getSymbolName(), DL);
} else {
const GlobalValue *GV = MO.getGlobal();
+
+ if (const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV))
+ if (GVar->hasAttribute("toc-data"))
+ return AP.getSymbol(GV);
+
TM.getNameWithPrefix(Name, GV, Mang);
}
Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -7097,6 +7097,8 @@
case PPC::ADDItocL:
Flags = PPCII::MO_TOC_LO;
break;
+ case PPC::ADDItoc:
+ break;
}
SDValue ImmOpnd = Base.getOperand(1);
@@ -7192,9 +7194,18 @@
}
if (FirstOp == 1) // Store
- (void)CurDAG->UpdateNodeOperands(N, N->getOperand(0), ImmOpnd,
- Base.getOperand(0), N->getOperand(3));
+ if (Base.getMachineOpcode() == PPC::ADDItoc)
+ (void)CurDAG->UpdateNodeOperands(N, N->getOperand(0),
+ Base.getOperand(0), Base.getOperand(1),
+ N->getOperand(3));
+ else
+ (void)CurDAG->UpdateNodeOperands(N, N->getOperand(0), ImmOpnd,
+ Base.getOperand(0), N->getOperand(3));
else // Load
+ if (Base.getMachineOpcode() == PPC::ADDItoc)
+ (void)CurDAG->UpdateNodeOperands(N, Base.getOperand(0),
+ Base.getOperand(1), N->getOperand(2));
+ else
(void)CurDAG->UpdateNodeOperands(N, ImmOpnd, Base.getOperand(0),
N->getOperand(2));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101470.341640.patch
Type: text/x-patch
Size: 3140 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210429/c0b2507d/attachment.bin>
More information about the llvm-commits
mailing list