}
}
+static bool isBranch(MachineInstr* MI) {
+ switch (MI->getOpcode()) {
+ default: { return false; }
+ case AArch64::B:
+ case AArch64::BR:
+ case AArch64::Bcc:
+ case AArch64::CBZW:
+ case AArch64::CBZX:
+ case AArch64::CBNZW:
+ case AArch64::CBNZX:
+ case AArch64::TBZW:
+ case AArch64::TBZX:
+ case AArch64::TBNZW:
+ case AArch64::TBNZX:
+ case AArch64::BLR:
+ case AArch64::BL:
+// case AArch64::BX:
+// case AArch64::BLX:
+ {
+ return true;
+ }
+ }
+}
+
bool AArch64LoadStoreOpt::optimizeBlock(MachineBasicBlock &MBB,
bool enableNarrowLdOpt) {
// XXX-update: Try to add a 'dmb ld' fence before a relaxed store in the form
DEBUG(dbgs() << "Added barrier instruction\n\t" << *DMBInst
<< "\n\tfor " << *MI << "\n");
// Skip all the way till we reach the end of the basic block or a load.
- while (MBBI != E && !isLoad(&*MBBI)) {
+ while (MBBI != E && !isLoad(&*MBBI) && !isBranch(MBBI)) {
MBBI++;
}
break;