[llvm] r267621 - [MachineInstrBundle] Improvement the recognition of dead definitions.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 26 16:14:24 PDT 2016


Author: qcolombet
Date: Tue Apr 26 18:14:24 2016
New Revision: 267621

URL: http://llvm.org/viewvc/llvm-project?rev=267621&view=rev
Log:
[MachineInstrBundle] Improvement the recognition of dead definitions.

Now, it is possible to know that partial definitions are dead definitions and
recognize that clobbered registers are also dead.

Modified:
    llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h
    llvm/trunk/lib/CodeGen/MachineInstrBundle.cpp
    llvm/trunk/test/CodeGen/X86/cmpxchg-clobber-flags.ll

Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h?rev=267621&r1=267620&r2=267621&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineInstrBundle.h Tue Apr 26 18:14:24 2016
@@ -187,6 +187,10 @@ public:
     /// dead.
     bool DeadDef;
 
+    /// Reg is Defined and all defs of reg or an overlapping register are
+    /// dead.
+    bool PartialDeadDef;
+
     /// There is a use operand of reg or a super-register with kill flag set.
     bool Killed;
   };

Modified: llvm/trunk/lib/CodeGen/MachineInstrBundle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstrBundle.cpp?rev=267621&r1=267620&r2=267621&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineInstrBundle.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineInstrBundle.cpp Tue Apr 26 18:14:24 2016
@@ -293,7 +293,7 @@ MachineOperandIteratorBase::PhysRegInfo
 MachineOperandIteratorBase::analyzePhysReg(unsigned Reg,
                                            const TargetRegisterInfo *TRI) {
   bool AllDefsDead = true;
-  PhysRegInfo PRI = {false, false, false, false, false, false, false};
+  PhysRegInfo PRI = {false, false, false, false, false, false, false, false};
 
   assert(TargetRegisterInfo::isPhysicalRegister(Reg) &&
          "analyzePhysReg not given a physical register!");
@@ -332,8 +332,12 @@ MachineOperandIteratorBase::analyzePhysR
     }
   }
 
-  if (AllDefsDead && PRI.FullyDefined)
-    PRI.DeadDef = true;
+  if (AllDefsDead) {
+    if (PRI.FullyDefined || PRI.Clobbered)
+      PRI.DeadDef = true;
+    else
+      PRI.PartialDeadDef = true;
+  }
 
   return PRI;
 }

Modified: llvm/trunk/test/CodeGen/X86/cmpxchg-clobber-flags.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmpxchg-clobber-flags.ll?rev=267621&r1=267620&r2=267621&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/cmpxchg-clobber-flags.ll (original)
+++ llvm/trunk/test/CodeGen/X86/cmpxchg-clobber-flags.ll Tue Apr 26 18:14:24 2016
@@ -63,11 +63,10 @@ define i64 @test_intervening_call(i64* %
 ; x8664-sahf-NEXT: popq %rax
 ; x8664-sahf-NEXT: movq %rax, %rdi
 ; x8664-sahf-NEXT: callq bar
-; x8664-sahf-NEXT: pushq %rax
+; RAX is dead, no need to push and pop it.
 ; x8664-sahf-NEXT: movq [[FLAGS]], %rax
 ; x8664-sahf-NEXT: addb $127, %al
 ; x8664-sahf-NEXT: sahf
-; x8664-sahf-NEXT: popq %rax
 ; x8664-sahf-NEXT: jne
 
   %cx = cmpxchg i64* %foo, i64 %bar, i64 %baz seq_cst seq_cst




More information about the llvm-commits mailing list