diff options
| author | Stuart Hastings <stuart@apple.com> | 2011-04-16 03:31:26 +0000 |
|---|---|---|
| committer | Stuart Hastings <stuart@apple.com> | 2011-04-16 03:31:26 +0000 |
| commit | ebddfe60a0e71a9da87b8d0d1545b839793cfe09 (patch) | |
| tree | 2103d641f670a3c3555464eeca4dded0e93a4b69 /llvm/lib/Target/ARM | |
| parent | b14ce09fcab9239940b74a72c66f2e99337e3835 (diff) | |
| download | bcm5719-llvm-ebddfe60a0e71a9da87b8d0d1545b839793cfe09.tar.gz bcm5719-llvm-ebddfe60a0e71a9da87b8d0d1545b839793cfe09.zip | |
Correct result when a branch condition is live across a block
boundary. <rdar://problem/8933028>
llvm-svn: 129634
Diffstat (limited to 'llvm/lib/Target/ARM')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMFastISel.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Target/ARM/ARMFastISel.cpp b/llvm/lib/Target/ARM/ARMFastISel.cpp index ce9e21fc2f3..c95b4a80e44 100644 --- a/llvm/lib/Target/ARM/ARMFastISel.cpp +++ b/llvm/lib/Target/ARM/ARMFastISel.cpp @@ -1121,10 +1121,16 @@ bool ARMFastISel::SelectBranch(const Instruction *I) { unsigned CmpReg = getRegForValue(BI->getCondition()); if (CmpReg == 0) return false; - // Re-set the flags just in case. - unsigned CmpOpc = isThumb ? ARM::t2CMPri : ARM::CMPri; - AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(CmpOpc)) - .addReg(CmpReg).addImm(0)); + // We've been divorced from our compare! Our block was split, and + // now our compare lives in a predecessor block. We musn't + // re-compare here, as the children of the compare aren't guaranteed + // live across the block boundary (we *could* check for this). + // Regardless, the compare has been done in the predecessor block, + // and it left a value for us in a virtual register. Ergo, we test + // the one-bit value left in the virtual register. + unsigned TstOpc = isThumb ? ARM::t2TSTri : ARM::TSTri; + AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TstOpc)) + .addReg(CmpReg).addImm(1)); unsigned BrOpc = isThumb ? ARM::t2Bcc : ARM::Bcc; BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(BrOpc)) |

