aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/CodeGen/SelectionDAG/InstrEmitter.cpp2
-rw-r--r--test/CodeGen/X86/sink-hoist.ll15
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
index d3ffb2a..425f670 100644
--- a/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
+++ b/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
@@ -571,6 +571,8 @@ void InstrEmitter::EmitNode(SDNode *Node, bool IsClone, bool IsCloned,
unsigned Reg = II.getImplicitDefs()[i - II.getNumDefs()];
if (Node->hasAnyUseOfValue(i))
EmitCopyFromReg(Node, i, IsClone, IsCloned, Reg, VRBaseMap);
+ else
+ MI->addRegisterDead(Reg, TRI);
}
}
return;
diff --git a/test/CodeGen/X86/sink-hoist.ll b/test/CodeGen/X86/sink-hoist.ll
index 4042a09..7f63669 100644
--- a/test/CodeGen/X86/sink-hoist.ll
+++ b/test/CodeGen/X86/sink-hoist.ll
@@ -41,3 +41,18 @@ bb:
return:
ret void
}
+
+; Sink instructions with dead EFLAGS defs.
+
+; CHECK: je
+; CHECK-NEXT: orb
+
+define zeroext i8 @zzz(i8 zeroext %a, i8 zeroext %b) nounwind readnone {
+entry:
+ %tmp = zext i8 %a to i32 ; <i32> [#uses=1]
+ %tmp2 = icmp eq i8 %a, 0 ; <i1> [#uses=1]
+ %tmp3 = or i8 %b, -128 ; <i8> [#uses=1]
+ %tmp4 = and i8 %b, 127 ; <i8> [#uses=1]
+ %b_addr.0 = select i1 %tmp2, i8 %tmp4, i8 %tmp3 ; <i8> [#uses=1]
+ ret i8 %b_addr.0
+}