[PATCH] D71833: [PowerPC] if value type is changed after folding rlwinm, stop folding

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 25 18:59:54 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rG1b57749a5334: [PowerPC] stop folding if result rlwinm mask is wrap while original rlwinm is… (authored by shchenz).

Changed prior to commit:
  https://reviews.llvm.org/D71833?vs=235309&id=235314#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71833

Files:
  llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
  llvm/test/CodeGen/PowerPC/fold-rlwinm.mir


Index: llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
===================================================================
--- llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
+++ llvm/test/CodeGen/PowerPC/fold-rlwinm.mir
@@ -77,6 +77,21 @@
     BLR8 implicit $lr8, implicit $rm
 ...
 ---
+name: testFoldRLWINMResultWrapped
+#CHECK : name : testFoldRLWINMResultWrapped
+tracksRegLiveness: true
+body: |
+  bb.0.entry:
+    liveins: $x3
+    %0:g8rc = COPY $x3
+    %1:gprc = COPY %0.sub_32:g8rc
+    %2:gprc = RLWINM %1:gprc, 10, 20, 10
+    ; CHECK: %2:gprc = RLWINM %1, 10, 20, 10
+    %3:gprc = RLWINM %2:gprc, 10, 0, 31
+    ; CHECK: %3:gprc = RLWINM %2, 10, 0, 31
+    BLR8 implicit $lr8, implicit $rm
+...
+---
 name: testFoldRLWINMMultipleUses
 #CHECK : name : testFoldRLWINMMultipleUses
 tracksRegLiveness: true
Index: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
+++ llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
@@ -919,8 +919,12 @@
 
           LLVM_DEBUG(dbgs() << "With: ");
           LLVM_DEBUG(MI.dump());
-        } else if (isRunOfOnes((unsigned)(FinalMask.getZExtValue()), NewMB,
-                               NewME) || SrcMaskFull) {
+        } else if ((isRunOfOnes((unsigned)(FinalMask.getZExtValue()), NewMB,
+                               NewME) && NewMB <= NewME)|| SrcMaskFull) {
+          // Here we only handle MBMI <= MEMI case, so NewMB must be no bigger
+          // than NewME. Otherwise we get a 64 bit value after folding, but MI
+          // return a 32 bit value.
+
           // If FoldingReg has only one use and it it not RLWINMo and
           // RLWINM8o, safe to delete its def SrcMI. Otherwise keep it.
           if (MRI->hasOneNonDBGUse(FoldingReg) &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71833.235314.patch
Type: text/x-patch
Size: 1797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191226/c391b3f9/attachment-0001.bin>


More information about the llvm-commits mailing list