diff options
author | Hiroshi Inoue <inouehrs@jp.ibm.com> | 2017-11-15 04:23:26 +0000 |
---|---|---|
committer | Hiroshi Inoue <inouehrs@jp.ibm.com> | 2017-11-15 04:23:26 +0000 |
commit | 72a1f98a6760940212677dc5706e3443c2a0f1e5 (patch) | |
tree | beee03203c8dd039c355d61245fa707e3524fb9e /llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | |
parent | fe7c045753172f3fccddecc163ed4ed5345c5dfe (diff) | |
download | bcm5719-llvm-72a1f98a6760940212677dc5706e3443c2a0f1e5.tar.gz bcm5719-llvm-72a1f98a6760940212677dc5706e3443c2a0f1e5.zip |
[PowerPC] fix up in redundant compare elimination
This patch fixes a potential problem in my previous commit (https://reviews.llvm.org/rL312514) by introducing an additional check.
llvm-svn: 318266
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCMIPeephole.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp b/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp index 80b7ac24345..0a84fe3bd41 100644 --- a/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp +++ b/llvm/lib/Target/PowerPC/PPCMIPeephole.cpp @@ -814,8 +814,12 @@ static bool eligibleForCompareElimination(MachineBasicBlock &MBB, !MRI->hasOneNonDBGUse(CndReg)) return false; - // We skip this BB if a physical register is used in comparison. MachineInstr *CMPI = MRI->getVRegDef(CndReg); + // We assume compare and branch are in the same BB for ease of analysis. + if (CMPI->getParent() != &BB) + return false; + + // We skip this BB if a physical register is used in comparison. for (MachineOperand &MO : CMPI->operands()) if (MO.isReg() && !TargetRegisterInfo::isVirtualRegister(MO.getReg())) return false; @@ -921,7 +925,7 @@ bool PPCMIPeephole::eliminateRedundantCompare(void) { // // As partially redundant case, we additionally handle if MBB2 has one // additional predecessor, which has only one successor (MBB2). - // In this case, we move the compre instruction originally in MBB2 into + // In this case, we move the compare instruction originally in MBB2 into // MBBtoMoveCmp. This partially redundant case is typically appear by // compiling a while loop; here, MBBtoMoveCmp is the loop preheader. // |