[PATCH] D77208: [PowerPC] Remove unnecessary XSRSP instruction in MI peephole
Qiu Chaofan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 03:50:58 PDT 2020
qiucf created this revision.
Herald added subscribers: llvm-commits, shchenz, kbarton, hiraditya, nemanjai.
Herald added a project: LLVM.
qiucf added a child revision: D64193: [PowerPC] Add exception constraint to FP rounding operations.
Herald added a subscriber: wuzish.
qiucf added reviewers: nemanjai, jsji, PowerPC.
This is found when looking at test results in D64193 <https://reviews.llvm.org/D64193>. Eliminate `xsrsp` instruction besides `frsp`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77208
Files:
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
llvm/test/CodeGen/PowerPC/mi-simplify-code.mir
Index: llvm/test/CodeGen/PowerPC/mi-simplify-code.mir
===================================================================
--- llvm/test/CodeGen/PowerPC/mi-simplify-code.mir
+++ llvm/test/CodeGen/PowerPC/mi-simplify-code.mir
@@ -56,7 +56,7 @@
# CHECK-LABEL: remove_xsrsp
# CHECK: sldi 4, 4, 2
# CHECK-NEXT: lfsux 0, 3, 4
-# CHECK-NEXT: xsrsp 0, 0
+# CHECK-NOT: xsrsp
# CHECK-NEXT: lfs 1, 8(3)
# CHECK-NEXT: xxmrghd 0, 1, 0
# CHECK-NEXT: xvcvdpsp 34, 0
Index: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
+++ llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
@@ -544,7 +544,8 @@
// Remove the passed FRSP instruction if it only feeds this MI and
// set any uses of that FRSP (in this MI) to the source of the FRSP.
auto removeFRSPIfPossible = [&](MachineInstr *RoundInstr) {
- if (RoundInstr->getOpcode() == PPC::FRSP &&
+ unsigned Opc = RoundInstr->getOpcode();
+ if ((Opc == PPC::FRSP || Opc == PPC::XSRSP) &&
MRI->hasOneNonDBGUse(RoundInstr->getOperand(0).getReg())) {
Simplified = true;
Register ConvReg1 = RoundInstr->getOperand(1).getReg();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77208.254150.patch
Type: text/x-patch
Size: 1267 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200401/eef15672/attachment.bin>
More information about the llvm-commits
mailing list