[PATCH] D88274: [PowerPC] Put the CR field in low bits of GRC during copying CRRC to GRC.

EsmeYi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 18:27:47 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4690b007743: [PowerPC] Put the CR field in low bits of GRC during copying CRRC to GRC. (authored by Esme).

Changed prior to commit:
  https://reviews.llvm.org/D88274?vs=294887&id=295711#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88274

Files:
  llvm/lib/Target/PowerPC/PPCInstrHTM.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/test/CodeGen/PowerPC/htm-ttest.ll


Index: llvm/test/CodeGen/PowerPC/htm-ttest.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/htm-ttest.ll
+++ llvm/test/CodeGen/PowerPC/htm-ttest.ll
@@ -8,7 +8,7 @@
 ; CHECK-NEXT:    li 3, 0
 ; CHECK-NEXT:    tabortwci. 0, 3, 0
 ; CHECK-NEXT:    mfocrf 3, 128
-; CHECK-NEXT:    rldicl 3, 3, 36, 28
+; CHECK-NEXT:    srwi 3, 3, 28
 ; CHECK-NEXT:    rlwinm. 3, 3, 31, 30, 31
 ; CHECK-NEXT:    beqlr+ 0
 ; CHECK-NEXT:  # %bb.1:
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -1272,14 +1272,22 @@
        .addImm(31);
     return;
   } else if (PPC::CRRCRegClass.contains(SrcReg) &&
-      PPC::G8RCRegClass.contains(DestReg)) {
-    BuildMI(MBB, I, DL, get(PPC::MFOCRF8), DestReg).addReg(SrcReg);
-    getKillRegState(KillSrc);
-    return;
-  } else if (PPC::CRRCRegClass.contains(SrcReg) &&
-      PPC::GPRCRegClass.contains(DestReg)) {
-    BuildMI(MBB, I, DL, get(PPC::MFOCRF), DestReg).addReg(SrcReg);
+             (PPC::G8RCRegClass.contains(DestReg) ||
+              PPC::GPRCRegClass.contains(DestReg))) {
+    bool Is64Bit = PPC::G8RCRegClass.contains(DestReg);
+    unsigned MvCode = Is64Bit ? PPC::MFOCRF8 : PPC::MFOCRF;
+    unsigned ShCode = Is64Bit ? PPC::RLWINM8 : PPC::RLWINM;
+    unsigned CRNum = TRI->getEncodingValue(SrcReg);
+    BuildMI(MBB, I, DL, get(MvCode), DestReg).addReg(SrcReg);
     getKillRegState(KillSrc);
+    if (CRNum == 7)
+      return;
+    // Shift the CR bits to make the CR field in the lowest 4 bits of GRC.
+    BuildMI(MBB, I, DL, get(ShCode), DestReg)
+        .addReg(DestReg, RegState::Kill)
+        .addImm(CRNum * 4 + 4)
+        .addImm(28)
+        .addImm(31);
     return;
   } else if (PPC::G8RCRegClass.contains(SrcReg) &&
              PPC::VSFRCRegClass.contains(DestReg)) {
Index: llvm/lib/Target/PowerPC/PPCInstrHTM.td
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrHTM.td
+++ llvm/lib/Target/PowerPC/PPCInstrHTM.td
@@ -164,9 +164,8 @@
           (TSR 0)>;
 
 def : Pat<(i64 (int_ppc_ttest)),
-          (RLDICL (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
-                                      (TABORTWCI 0, (LI 0), 0), sub_32)),
-                   36, 28)>;
+          (i64 (INSERT_SUBREG
+                (i64 (IMPLICIT_DEF)), (TABORTWCI 0, (LI 0), 0), sub_32))>;
 
 } // [HasHTM]
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88274.295711.patch
Type: text/x-patch
Size: 2516 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201002/98282f91/attachment.bin>


More information about the llvm-commits mailing list