[PATCH] D27508: [CodeGen] Make MachineInstr::isIdenticalTo() symmetric.

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 19 03:31:32 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL290095: [CodeGen] Make MachineInstr::isIdenticalTo() symmetric. (authored by bjope).

Changed prior to commit:
  https://reviews.llvm.org/D27508?vs=81752&id=81933#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D27508

Files:
  llvm/trunk/lib/CodeGen/MachineInstr.cpp


Index: llvm/trunk/lib/CodeGen/MachineInstr.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/MachineInstr.cpp
+++ llvm/trunk/lib/CodeGen/MachineInstr.cpp
@@ -1000,16 +1000,24 @@
     return false;
 
   if (isBundle()) {
-    // Both instructions are bundles, compare MIs inside the bundle.
+    // We have passed the test above that both instructions have the same
+    // opcode, so we know that both instructions are bundles here. Let's compare
+    // MIs inside the bundle.
+    assert(Other.isBundle() && "Expected that both instructions are bundles.");
     MachineBasicBlock::const_instr_iterator I1 = getIterator();
-    MachineBasicBlock::const_instr_iterator E1 = getParent()->instr_end();
     MachineBasicBlock::const_instr_iterator I2 = Other.getIterator();
-    MachineBasicBlock::const_instr_iterator E2 = Other.getParent()->instr_end();
-    while (++I1 != E1 && I1->isInsideBundle()) {
+    // Loop until we analysed the last intruction inside at least one of the
+    // bundles.
+    while (I1->isBundledWithSucc() && I2->isBundledWithSucc()) {
+      ++I1;
       ++I2;
-      if (I2 == E2 || !I2->isInsideBundle() || !I1->isIdenticalTo(*I2, Check))
+      if (!I1->isIdenticalTo(*I2, Check))
         return false;
     }
+    // If we've reached the end of just one of the two bundles, but not both,
+    // the instructions are not identical.
+    if (I1->isBundledWithSucc() || I2->isBundledWithSucc())
+      return false;
   }
 
   // Check operands to make sure they match.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27508.81933.patch
Type: text/x-patch
Size: 1550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161219/9ee3ced5/attachment-0001.bin>


More information about the llvm-commits mailing list