<div dir="ltr">Hi Jonas,<div><br></div><div>I reverted this in r273707 as it caused PR28295.</div><div><br></div><div>I should have a reproducer for you soon.</div><div><br></div><div>Thanks,</div><div>Peter</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 23, 2016 at 1:13 AM, Jonas Paulsson via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jonpa<br>
Date: Thu Jun 23 03:13:20 2016<br>
New Revision: 273545<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=273545&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=273545&view=rev</a><br>
Log:<br>
[IfConversion] Bugfix: Don't use undef flag while adding use operands.<br>
<br>
IfConversion used to always add the undef flag when adding a use operand<br>
on a newly predicated instruction. This would be an operand for the register<br>
being conditionally redefined. Due to the undef flag, the liveness of this<br>
register prior to the predicated instruction would get lost.<br>
<br>
This patch changes this so that such use operands are added only when the<br>
register is live, without the undef flag.<br>
<br>
Reviewed by Quentin Colombet.<br>
<a href="http://reviews.llvm.org/D209077" rel="noreferrer" target="_blank">http://reviews.llvm.org/D209077</a><br>
<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/IfConversion.cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=273545&r1=273544&r2=273545&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=273545&r1=273544&r2=273545&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/IfConversion.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/IfConversion.cpp Thu Jun 23 03:13:20 2016<br>
@@ -1046,8 +1046,19 @@ void IfConverter::RemoveExtraEdges(BBInf<br>
 }<br>
<br>
 /// Behaves like LiveRegUnits::StepForward() but also adds implicit uses to all<br>
-/// values defined in MI which are not live/used by MI.<br>
+/// values defined in MI which are also live/used by MI.<br>
 static void UpdatePredRedefs(MachineInstr &MI, LivePhysRegs &Redefs) {<br>
+  const TargetRegisterInfo *TRI = MI.getParent()->getParent()<br>
+    ->getSubtarget().getRegisterInfo();<br>
+<br>
+  // Before stepping forward past MI, remember which regs were live<br>
+  // before MI. This is needed to set the Undef flag only when reg is<br>
+  // dead.<br>
+  SparseSet<unsigned> LiveBeforeMI;<br>
+  LiveBeforeMI.setUniverse(TRI->getNumRegs());<br>
+  for (auto &Reg : Redefs)<br>
+    LiveBeforeMI.insert(Reg);<br>
+<br>
   SmallVector<std::pair<unsigned, const MachineOperand*>, 4> Clobbers;<br>
   Redefs.stepForward(MI, Clobbers);<br>
<br>
@@ -1061,7 +1072,8 @@ static void UpdatePredRedefs(MachineInst<br>
     if (Op.isRegMask()) {<br>
       // First handle regmasks.  They clobber any entries in the mask which<br>
       // means that we need a def for those registers.<br>
-      MIB.addReg(Reg.first, RegState::Implicit | RegState::Undef);<br>
+      if (LiveBeforeMI.count(Reg.first))<br>
+        MIB.addReg(Reg.first, RegState::Implicit);<br>
<br>
       // We also need to add an implicit def of this register for the later<br>
       // use to read from.<br>
@@ -1078,7 +1090,8 @@ static void UpdatePredRedefs(MachineInst<br>
       if (Redefs.contains(Op.getReg()))<br>
         Op.setIsDead(false);<br>
     }<br>
-    MIB.addReg(Reg.first, RegState::Implicit | RegState::Undef);<br>
+    if (LiveBeforeMI.count(Reg.first))<br>
+      MIB.addReg(Reg.first, RegState::Implicit);<br>
   }<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">-- <div>Peter</div></div></div>
</div>