From 2eab0e30e1e4316c6b3fd554864b9c8df3de84e6 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Mon, 16 Feb 2015 19:34:27 +0000 Subject: [PATCH] RegisterCoalescer: Improve previous fix for wrong def after. The previous fix in r225503 was needlessly complicated. The problem goes away as well if the arguments to MergeValueNumberInto are supplied in the correct order. This was previously missed because the existing code already had the wrong order but an additional later Merge was hiding the bug for the main liverange VNI. llvm-svn: 229424 --- llvm/lib/CodeGen/RegisterCoalescer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/llvm/lib/CodeGen/RegisterCoalescer.cpp b/llvm/lib/CodeGen/RegisterCoalescer.cpp index 5cc11ae0309d..65b0e5026f09 100644 --- a/llvm/lib/CodeGen/RegisterCoalescer.cpp +++ b/llvm/lib/CodeGen/RegisterCoalescer.cpp @@ -738,15 +738,14 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP, continue; DEBUG(dbgs() << "\t\tnoop: " << DefIdx << '\t' << *UseMI); assert(DVNI->def == DefIdx); - BValNo = IntB.MergeValueNumberInto(BValNo, DVNI); + BValNo = IntB.MergeValueNumberInto(DVNI, BValNo); for (LiveInterval::SubRange &S : IntB.subranges()) { VNInfo *SubDVNI = S.getVNInfoAt(DefIdx); if (!SubDVNI) continue; VNInfo *SubBValNo = S.getVNInfoAt(CopyIdx); assert(SubBValNo->def == CopyIdx); - VNInfo *Merged = S.MergeValueNumberInto(SubBValNo, SubDVNI); - Merged->def = CopyIdx; + S.MergeValueNumberInto(SubDVNI, SubBValNo); } ErasedInstrs.insert(UseMI);