[llvm] r184002 - Mark rematerialized super/sub registers as dead.

Tim Northover tnorthover at apple.com
Fri Jun 14 13:22:21 PDT 2013


Author: tnorthover
Date: Fri Jun 14 15:22:21 2013
New Revision: 184002

URL: http://llvm.org/viewvc/llvm-project?rev=184002&view=rev
Log:
Mark rematerialized super/sub registers as dead.

When we're rematerializing into a not-quite-right register we already add the
real definition as an imp-def, but we should also be marking the "official"
register as dead, since nothing else is going to use it as a result of this
remat.

Not doing this can affect pressure tracking.

rdar://problem/14158833

Added:
    llvm/trunk/test/CodeGen/X86/remat-phys-dead.ll
Modified:
    llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp

Modified: llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp?rev=184002&r1=184001&r2=184002&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp Fri Jun 14 15:22:21 2013
@@ -843,6 +843,7 @@ bool RegisterCoalescer::reMaterializeTri
     // been asked for. If so it must implicitly define the whole thing.
     assert(TargetRegisterInfo::isPhysicalRegister(DstReg) &&
            "Only expect virtual or physical registers in remat");
+    NewMI->getOperand(0).setIsDead(true);
     NewMI->addOperand(MachineOperand::CreateReg(CopyDstReg,
                                                 true  /*IsDef*/,
                                                 true  /*IsImp*/,

Added: llvm/trunk/test/CodeGen/X86/remat-phys-dead.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/remat-phys-dead.ll?rev=184002&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/remat-phys-dead.ll (added)
+++ llvm/trunk/test/CodeGen/X86/remat-phys-dead.ll Fri Jun 14 15:22:21 2013
@@ -0,0 +1,23 @@
+; REQUIRES: asserts
+; RUN: llc -mtriple=x86_64-apple-darwin -debug -o /dev/null < %s 2>&1 | FileCheck %s
+
+; We need to make sure that rematerialization into a physical register marks the
+; super- or sub-register as dead after this rematerialization since only the
+; original register is actually used later. Largely irrelevant for a trivial
+; example like this, since EAX is never used again, but easy to test.
+
+define i8 @test_remat() {
+  ret i8 0
+; CHECK: REGISTER COALESCING
+; CHECK: Remat: %EAX<def,dead> = MOV32r0 %EFLAGS<imp-def,dead>, %AL<imp-def>
+}
+
+; On the other hand, if it's already the correct width, we really shouldn't be
+; marking the definition register as dead.
+
+define i32 @test_remat32() {
+  ret i32 0
+; CHECK: REGISTER COALESCING
+; CHECK: Remat: %EAX<def> = MOV32r0 %EFLAGS<imp-def,dead>
+}
+





More information about the llvm-commits mailing list