From: Chris Lattner Date: Fri, 3 Feb 2006 02:02:59 +0000 (+0000) Subject: Add code that checks for noop copies, which triggers when either: X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=1118d25d3971bc4fce9715c8c83ea7a197bf2eff;p=oota-llvm.git Add code that checks for noop copies, which triggers when either: 1. a target doesn't know how to fold load/stores into copies, or 2. the spiller rewrites the input to a copy to the same register as the dest instead of to the reloaded reg. This will be moved/improved in the near future, but allows elimination of some ancient x86 hacks. This eliminates 92 copies from SMG2000 on X86 and 163 copies from 252.eon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25922 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp index 608ff8bd8cd..0487890bc98 100644 --- a/lib/CodeGen/VirtRegMap.cpp +++ b/lib/CodeGen/VirtRegMap.cpp @@ -38,6 +38,7 @@ namespace { Statistic<> NumLoads ("spiller", "Number of loads added"); Statistic<> NumReused("spiller", "Number of values reused"); Statistic<> NumDSE ("spiller", "Number of dead stores elided"); + Statistic<> NumDCE ("spiller", "Number of copies elided"); enum SpillerName { simple, local }; @@ -658,6 +659,18 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM) { } } } + + // Okay, the instruction has been completely processed, input and output + // registers have been added. As a final sanity check, make sure this is + // not a noop-copy. If it is, nuke it. + { + unsigned Src, Dst; + if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) { + ++NumDCE; + DEBUG(std::cerr << "Removing now-noop copy: " << MI); + MBB.erase(&MI); + } + } ProcessNextInst: MII = NextMII; }