[PATCH] D77208: [PowerPC] Remove unnecessary XSRSP instruction in MI peephole

Qiu Chaofan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 20:36:53 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG71f1ab53544c: [PowerPC] Remove unnecessary XSRSP instruction (authored by qiucf).

Changed prior to commit:
  https://reviews.llvm.org/D77208?vs=254150&id=254689#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77208/new/

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
@@ -541,10 +541,12 @@
           if (!P1 || !P2)
             break;
 
-          // 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.
+          // Remove the passed FRSP/XSRSP instruction if it only feeds this MI
+          // and set any uses of that FRSP/XSRSP (in this MI) to the source of
+          // the FRSP/XSRSP.
           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();
@@ -554,7 +556,7 @@
                 if (Use.getOperand(i).isReg() &&
                     Use.getOperand(i).getReg() == FRSPDefines)
                   Use.getOperand(i).setReg(ConvReg1);
-              LLVM_DEBUG(dbgs() << "Removing redundant FRSP:\n");
+              LLVM_DEBUG(dbgs() << "Removing redundant FRSP/XSRSP:\n");
               LLVM_DEBUG(RoundInstr->dump());
               LLVM_DEBUG(dbgs() << "As it feeds instruction:\n");
               LLVM_DEBUG(MI.dump());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77208.254689.patch
Type: text/x-patch
Size: 1989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200403/e46e7092/attachment.bin>


More information about the llvm-commits mailing list