[PATCH] D17554: MachineInstr: Respect register aliases in clearRegiserKills()

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 24 11:26:27 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL261763: MachineInstr: Respect register aliases in clearRegiserKills() (authored by matze).

Changed prior to commit:
  http://reviews.llvm.org/D17554?vs=48854&id=48964#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17554

Files:
  llvm/trunk/include/llvm/CodeGen/MachineInstr.h
  llvm/trunk/lib/CodeGen/MachineInstr.cpp
  llvm/trunk/test/CodeGen/X86/machine-copy-prop.mir

Index: llvm/trunk/lib/CodeGen/MachineInstr.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/MachineInstr.cpp
+++ llvm/trunk/lib/CodeGen/MachineInstr.cpp
@@ -1967,7 +1967,7 @@
     if (!MO.isReg() || !MO.isUse() || !MO.isKill())
       continue;
     unsigned OpReg = MO.getReg();
-    if (OpReg == Reg || (RegInfo && RegInfo->isSuperRegister(Reg, OpReg)))
+    if ((RegInfo && RegInfo->regsOverlap(Reg, OpReg)) || Reg == OpReg)
       MO.setIsKill(false);
   }
 }
Index: llvm/trunk/include/llvm/CodeGen/MachineInstr.h
===================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineInstr.h
+++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h
@@ -1083,8 +1083,8 @@
                          const TargetRegisterInfo *RegInfo,
                          bool AddIfNotFound = false);
 
-  /// Clear all kill flags affecting Reg.  If RegInfo is
-  /// provided, this includes super-register kills.
+  /// Clear all kill flags affecting Reg.  If RegInfo is provided, this includes
+  /// all aliasing registers.
   void clearRegisterKills(unsigned Reg, const TargetRegisterInfo *RegInfo);
 
   /// We have determined MI defined a register without a use.
Index: llvm/trunk/test/CodeGen/X86/machine-copy-prop.mir
===================================================================
--- llvm/trunk/test/CodeGen/X86/machine-copy-prop.mir
+++ llvm/trunk/test/CodeGen/X86/machine-copy-prop.mir
@@ -0,0 +1,59 @@
+# RUN: llc -march=x86 -run-pass machine-cp -verify-machineinstrs -o /dev/null %s 2>&1 | FileCheck %s
+
+--- |
+  declare void @foo()
+  define void @copyprop_remove_kill0() { ret void }
+  define void @copyprop_remove_kill1() { ret void }
+  define void @copyprop_remove_kill2() { ret void }
+...
+---
+# The second copy is redundand and will be removed, check that we also remove
+# the kill flag of intermediate instructions.
+# CHECK-LABEL: name: copyprop_remove_kill0
+# CHECK: bb.0:
+# CHECK-NEXT: %rax = COPY %rdi
+# CHECK-NEXT: NOOP implicit %rdi
+# CHECK-NOT: COPY
+# CHECK-NEXT: NOOP implicit %rax, implicit %rdi
+name: copyprop_remove_kill0
+body: |
+  bb.0:
+    %rax = COPY %rdi
+    NOOP implicit killed %rdi
+    %rdi = COPY %rax
+    NOOP implicit %rax, implicit %rdi
+...
+---
+# The second copy is redundand and will be removed, check that we also remove
+# the kill flag of intermediate instructions.
+# CHECK-LABEL: name: copyprop_remove_kill1
+# CHECK: bb.0:
+# CHECK-NEXT: %rax = COPY %rdi
+# CHECK-NEXT: NOOP implicit %edi
+# CHECK-NOT: COPY
+# CHECK-NEXT: NOOP implicit %rax, implicit %rdi
+name: copyprop_remove_kill1
+body: |
+  bb.0:
+    %rax = COPY %rdi
+    NOOP implicit killed %edi
+    %rdi = COPY %rax
+    NOOP implicit %rax, implicit %rdi
+...
+---
+# The second copy is redundand and will be removed, check that we also remove
+# the kill flag of intermediate instructions.
+# CHECK-LABEL: name: copyprop_remove_kill2
+# CHECK: bb.0:
+# CHECK-NEXT: %ax = COPY %di
+# CHECK-NEXT: NOOP implicit %rdi
+# CHECK-NOT: COPY
+# CHECK-NEXT: NOOP implicit %rax, implicit %rdi
+name: copyprop_remove_kill2
+body: |
+  bb.0:
+    %ax = COPY %di
+    NOOP implicit killed %rdi
+    %di = COPY %ax
+    NOOP implicit %rax, implicit %rdi
+...


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17554.48964.patch
Type: text/x-patch
Size: 3259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160224/499a27a6/attachment.bin>


More information about the llvm-commits mailing list