diff options
| author | Philip Reames <listmail@philipreames.com> | 2016-01-06 19:33:12 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2016-01-06 19:33:12 +0000 |
| commit | 5eb90a7835b9558b151aafb88f1cca6f7f5e9c92 (patch) | |
| tree | c67e649885be47fa4c43824c710e28e3b2a12dd0 /llvm/lib/CodeGen/BranchFolding.cpp | |
| parent | eea7582bfa3b30393af643fab1e30008a930e319 (diff) | |
| download | llvm-5eb90a7835b9558b151aafb88f1cca6f7f5e9c92.zip llvm-5eb90a7835b9558b151aafb88f1cca6f7f5e9c92.tar.gz llvm-5eb90a7835b9558b151aafb88f1cca6f7f5e9c92.tar.bz2 | |
Consolidate MemRefs handling from BranchFolding and correct latent bug
Move the logic from BranchFolding to use the shared infrastructure for merging MMOs introduced in 256909. This has the effect of making BranchFolding more capable.
In the process, fix a latent bug. The existing handling for merging didn't handle the case where one of the instructions being merged had overflowed and dropped MemRefs. This was a latent bug in the places the code was commoned from, but potentially reachable in BranchFolding.
Once this is in, we're left with a single place to consider implementing MMO unique-ing as proposed in http://reviews.llvm.org/D15230.
Differential Revision: http://reviews.llvm.org/D15913
llvm-svn: 256966
Diffstat (limited to 'llvm/lib/CodeGen/BranchFolding.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/BranchFolding.cpp | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp index 604feedd..6080349 100644 --- a/llvm/lib/CodeGen/BranchFolding.cpp +++ b/llvm/lib/CodeGen/BranchFolding.cpp @@ -744,18 +744,6 @@ bool BranchFolder::CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB, return true; } -static bool hasIdenticalMMOs(const MachineInstr *MI1, const MachineInstr *MI2) { - auto I1 = MI1->memoperands_begin(), E1 = MI1->memoperands_end(); - auto I2 = MI2->memoperands_begin(), E2 = MI2->memoperands_end(); - if ((E1 - I1) != (E2 - I2)) - return false; - for (; I1 != E1; ++I1, ++I2) { - if (**I1 != **I2) - return false; - } - return true; -} - static void removeMMOsFromMemoryOperations(MachineBasicBlock::iterator MBBIStartPos, MachineBasicBlock &MBBCommon) { @@ -792,8 +780,7 @@ removeMMOsFromMemoryOperations(MachineBasicBlock::iterator MBBIStartPos, assert(MBBICommon->isIdenticalTo(&*MBBI) && "Expected matching MIIs!"); if (MBBICommon->mayLoad() || MBBICommon->mayStore()) - if (!hasIdenticalMMOs(&*MBBI, &*MBBICommon)) - MBBICommon->dropMemRefs(); + MBBICommon->setMemRefs(MBBI->mergeMemRefsWith(*MBBI)); ++MBBI; ++MBBICommon; |
