aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/IfConversion.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2010-06-18 21:52:57 +0000
committerEvan Cheng <evan.cheng@apple.com>2010-06-18 21:52:57 +0000
commita9934dc20a5e137a35be6f640c79fda9261f985b (patch)
treee529797dea8663564b323bebff142d720edfcc00 /lib/CodeGen/IfConversion.cpp
parente03262fcfc09356a0e3ec589041bc2e0248944e9 (diff)
downloadexternal_llvm-a9934dc20a5e137a35be6f640c79fda9261f985b.zip
external_llvm-a9934dc20a5e137a35be6f640c79fda9261f985b.tar.gz
external_llvm-a9934dc20a5e137a35be6f640c79fda9261f985b.tar.bz2
Teach iff-converter to properly count # of dups. It was not skipping over dbg_value's which resulted in non-duplicated instructions being deleted. rdar://8104384.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106323 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/IfConversion.cpp')
-rw-r--r--lib/CodeGen/IfConversion.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp
index f82b2f0..dad5218 100644
--- a/lib/CodeGen/IfConversion.cpp
+++ b/lib/CodeGen/IfConversion.cpp
@@ -531,6 +531,19 @@ bool IfConverter::ValidDiamond(BBInfo &TrueBBI, BBInfo &FalseBBI,
while (FI != FIE && FI->isDebugValue())
++FI;
while (TI != TIE && FI != FIE) {
+ // Skip dbg_value instructions. These do not count.
+ if (TI->isDebugValue()) {
+ while (TI != TIE && TI->isDebugValue())
+ ++TI;
+ if (TI == TIE)
+ break;
+ }
+ if (FI->isDebugValue()) {
+ while (FI != FIE && FI->isDebugValue())
+ ++FI;
+ if (FI == FIE)
+ break;
+ }
if (!TI->isIdenticalTo(FI))
break;
++Dups1;
@@ -542,12 +555,25 @@ bool IfConverter::ValidDiamond(BBInfo &TrueBBI, BBInfo &FalseBBI,
FI = firstNonBranchInst(FalseBBI.BB, TII);
MachineBasicBlock::iterator TIB = TrueBBI.BB->begin();
MachineBasicBlock::iterator FIB = FalseBBI.BB->begin();
- // Skip dbg_value instructions
+ // Skip dbg_value instructions at end of the bb's.
while (TI != TIB && TI->isDebugValue())
--TI;
while (FI != FIB && FI->isDebugValue())
--FI;
while (TI != TIB && FI != FIB) {
+ // Skip dbg_value instructions. These do not count.
+ if (TI->isDebugValue()) {
+ while (TI != TIB && TI->isDebugValue())
+ --TI;
+ if (TI == TIB)
+ break;
+ }
+ if (FI->isDebugValue()) {
+ while (FI != FIB && FI->isDebugValue())
+ --FI;
+ if (FI == FIB)
+ break;
+ }
if (!TI->isIdenticalTo(FI))
break;
++Dups2;