[PATCH] D83569: [PowerPC] Fix the killed flag in mi-peephole pass

Zhang Kang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 10 09:28:29 PDT 2020


ZhangKang created this revision.
ZhangKang added reviewers: PowerPC, nemanjai, jsji, steven.zhang.
ZhangKang added a project: LLVM.
Herald added subscribers: shchenz, wuzish, hiraditya.

When doing the peephole 'RLDICL + RLDICR --> RLDIC', we forget to move the killed flag 
from srcMI to destMI.

This patch is to fix this bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83569

Files:
  llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
  llvm/test/CodeGen/PowerPC/mi-peephole.mir


Index: llvm/test/CodeGen/PowerPC/mi-peephole.mir
===================================================================
--- llvm/test/CodeGen/PowerPC/mi-peephole.mir
+++ llvm/test/CodeGen/PowerPC/mi-peephole.mir
@@ -31,7 +31,7 @@
   ; CHECK: bb.0.entry:
   ; CHECK:   %1:g8rc = COPY $x4
   ; CHECK:   %0:g8rc = COPY $x3
-  ; CHECK:   %3:g8rc = RLDIC %1, 2, 30
+  ; CHECK:   %3:g8rc = RLDIC killed %1, 2, 30
   ; CHECK:   $x3 = COPY %3
   ; CHECK:   BLR8 implicit $lr8, implicit $rm, implicit $x3
 ...
Index: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
+++ llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
@@ -1556,6 +1556,11 @@
   MI.getOperand(2).setImm(NewSH);
   MI.getOperand(3).setImm(NewMB);
 
+  if (SrcMI->getOperand(1).isKill()) {
+    MI.getOperand(1).setIsKill(true);
+    SrcMI->getOperand(1).setIsKill(false);
+  }
+
   LLVM_DEBUG(dbgs() << "To: ");
   LLVM_DEBUG(MI.dump());
   NumRotatesCollapsed++;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83569.277073.patch
Type: text/x-patch
Size: 1017 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200710/7380d444/attachment.bin>


More information about the llvm-commits mailing list