[PATCH] D29525: MachineCopyPropagation: Do not consider undef operands as clobbers

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 18:38:41 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL294087: MachineCopyPropagation: Do not consider undef operands as clobbers (authored by matze).

Changed prior to commit:
  https://reviews.llvm.org/D29525?vs=87061&id=87067#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29525

Files:
  llvm/trunk/lib/CodeGen/MachineCopyPropagation.cpp
  llvm/trunk/test/CodeGen/X86/copy-propagation.ll


Index: llvm/trunk/test/CodeGen/X86/copy-propagation.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/copy-propagation.ll
+++ llvm/trunk/test/CodeGen/X86/copy-propagation.ll
@@ -1,38 +1,25 @@
 ; RUN: llc %s -mattr=+avx -o - | FileCheck %s
-; PR21743.
+; Originally from http://llvm.org/PR21743.
 
 target triple = "x86_64-pc-win32-elf"
 
-; Check that copy propagation conservatively assumes that undef register
-; can be rewritten by the backend to break false dependencies for the
-; hardware.
-; In this function we are in this situation:
-; reg1 = copy reg2
-; = inst reg2<undef>
-; reg2 = copy reg1
-; Copy propagation used to remove the last copy.
-; This is incorrect because the undef flag on reg2 in inst, allows next
-; passes to put whatever trashed value in reg2 that may help.
-; In practice we end up with this code:
-; reg1 = copy reg2
-; reg2 = 0
-; = inst reg2<undef>
-; reg2 = copy reg1
-; Therefore, removing the last copy is wrong.
+; Copy propagation may remove COPYs if the result is only used by undef
+; operands.
 ;
 ; CHECK-LABEL: foo:
 ; CHECK: movl	$339752784, %e[[INDIRECT_CALL1:[a-z]+]]
 ; CHECK: callq *%r[[INDIRECT_CALL1]]
 ; Copy the result in a temporary.
-; Note: Technically the regalloc could have been smarter and this move not required,
-; which would have hidden the bug.
+; Note: Technically the regalloc could have been smarter and this move not
+; required, which would have hidden the bug.
 ; CHECK: vmovapd	%xmm0, [[TMP:%xmm[0-9]+]]
-; Crush xmm0.
-; CHECK-NEXT: vxorps %xmm0, %xmm0, %xmm0
+; CHECK-NOT: vxorps  %xmm0, %xmm0, %xmm0
+; CHECK-NEXT: vcvtsi2sdq      %rsi, %xmm0, %xmm6
 ; CHECK: movl	$339772768, %e[[INDIRECT_CALL2:[a-z]+]]
+; CHECK-NOT: vmovapd %xmm7, %xmm0
+; CHECK-NEXT: vmovapd %xmm6, %xmm1
 ; Set TMP in the first argument of the second call.
-; CHECK-NEXT: vmovapd	[[TMP]], %xmm0
-; CHECK: callq *%r[[INDIRECT_CALL2]]
+; CHECK_NEXT: callq *%r[[INDIRECT_CALL2]]
 ; CHECK: retq
 define double @foo(i64 %arg) {
 top:
Index: llvm/trunk/lib/CodeGen/MachineCopyPropagation.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/MachineCopyPropagation.cpp
+++ llvm/trunk/lib/CodeGen/MachineCopyPropagation.cpp
@@ -280,14 +280,6 @@
           MaybeDeadCopies.remove(CI->second);
         }
       }
-      // Treat undef use like defs for copy propagation but not for
-      // dead copy. We would need to do a liveness check to be sure the copy
-      // is dead for undef uses.
-      // The backends are allowed to do whatever they want with undef value
-      // and we cannot be sure this register will not be rewritten to break
-      // some false dependencies for the hardware for instance.
-      if (MO.isUndef())
-        Defs.push_back(Reg);
     }
 
     // The instruction has a register mask operand which means that it clobbers


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29525.87067.patch
Type: text/x-patch
Size: 2897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170204/de0e9562/attachment.bin>


More information about the llvm-commits mailing list