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