From a079ef68e373fffd6e6d14c11c26d9ba85f16e98 Mon Sep 17 00:00:00 2001 From: Mikael Holmen Date: Thu, 12 Oct 2017 06:21:28 +0000 Subject: [RegisterCoalescer] Don't set read-undef in pruneValues, only clear Summary: The comments in the code said // Remove flags. This def is now a partial redef. but the code didn't just remove read-undef, it could introduce new ones which could cause errors. E.g. if we have something like %vreg1 = IMPLICIT_DEF %vreg2:subreg1 = op %vreg3, %vreg4 %vreg2:subreg2 = op %vreg6, %vreg7 and we merge %vreg1 and %vreg2 then we should not set undef on the second subreg def, which the old code did. Now we solve this by actually do what the code comment says. We remove read-undef flags rather than remove or introduce them. Reviewers: qcolombet, MatzeB Reviewed By: MatzeB Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D38616 llvm-svn: 315564 --- llvm/lib/CodeGen/RegisterCoalescer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp index 30b2686d620..1ef7e41b8ae 100644 --- a/llvm/lib/CodeGen/RegisterCoalescer.cpp +++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp @@ -2685,8 +2685,8 @@ void JoinVals::pruneValues(JoinVals &Other, for (MachineOperand &MO : Indexes->getInstructionFromIndex(Def)->operands()) { if (MO.isReg() && MO.isDef() && MO.getReg() == Reg) { - if (MO.getSubReg() != 0) - MO.setIsUndef(EraseImpDef); + if (MO.getSubReg() != 0 && MO.isUndef() && !EraseImpDef) + MO.setIsUndef(false); MO.setIsDead(false); } } -- cgit v1.2.3