[DAG] Don't pull the binary operation though the shift if the operands have opaque...
[oota-llvm.git] / lib / CodeGen / ExpandPostRAPseudos.cpp
index f71c453b6ef912deef9e00b2ad03db4c72a38a44..6c73fffb2015f4d99ef1bbf3e1f46e147165bab7 100644 (file)
@@ -97,8 +97,14 @@ bool ExpandPostRA::LowerSubregToReg(MachineInstr *MI) {
 
   DEBUG(dbgs() << "subreg: CONVERTING: " << *MI);
 
+  if (MI->allDefsAreDead()) {
+    MI->setDesc(TII->get(TargetOpcode::KILL));
+    DEBUG(dbgs() << "subreg: replaced by: " << *MI);
+    return true;
+  }
+
   if (DstSubReg == InsReg) {
-    // No need to insert an identify copy instruction.
+    // No need to insert an identity copy instruction.
     // Watch out for case like this:
     // %RAX<def> = SUBREG_TO_REG 0, %EAX<kill>, 3
     // We must leave %RAX live.
@@ -111,13 +117,9 @@ bool ExpandPostRA::LowerSubregToReg(MachineInstr *MI) {
     }
     DEBUG(dbgs() << "subreg: eliminated!");
   } else {
-    if (MI->getOperand(0).isDead()) {
-      MI->setDesc(TII->get(TargetOpcode::KILL));
-      DEBUG(dbgs() << "subreg: replaced by: " << *MI);
-      return true;
-    }
     TII->copyPhysReg(*MBB, MI, MI->getDebugLoc(), DstSubReg, InsReg,
                      MI->getOperand(2).isKill());
+
     // Implicitly define DstReg for subsequent uses.
     MachineBasicBlock::iterator CopyMI = MI;
     --CopyMI;
@@ -131,16 +133,17 @@ bool ExpandPostRA::LowerSubregToReg(MachineInstr *MI) {
 }
 
 bool ExpandPostRA::LowerCopy(MachineInstr *MI) {
-  MachineOperand &DstMO = MI->getOperand(0);
-  MachineOperand &SrcMO = MI->getOperand(1);
 
-  if (DstMO.isDead()) {
+  if (MI->allDefsAreDead()) {
     DEBUG(dbgs() << "dead copy: " << *MI);
     MI->setDesc(TII->get(TargetOpcode::KILL));
     DEBUG(dbgs() << "replaced by: " << *MI);
     return true;
   }
 
+  MachineOperand &DstMO = MI->getOperand(0);
+  MachineOperand &SrcMO = MI->getOperand(1);
+
   if (SrcMO.getReg() == DstMO.getReg()) {
     DEBUG(dbgs() << "identity copy: " << *MI);
     // No need to insert an identity copy instruction, but replace with a KILL