aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-08-07 23:17:52 +0000
committerDevang Patel <dpatel@apple.com>2007-08-07 23:17:52 +0000
commit002fe25dd7ae240369eae70195ccf17b8921585f (patch)
tree7e53327c9ea71052b2db24fc7ae8cc415f7dd6c0
parenta9e9286630262092e404c6b3c6ecf159b50a87b9 (diff)
downloadexternal_llvm-002fe25dd7ae240369eae70195ccf17b8921585f.zip
external_llvm-002fe25dd7ae240369eae70195ccf17b8921585f.tar.gz
external_llvm-002fe25dd7ae240369eae70195ccf17b8921585f.tar.bz2
Fix new compare instruction's signness. Caught by Chris during review.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40912 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/LoopIndexSplit.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/LoopIndexSplit.cpp b/lib/Transforms/Scalar/LoopIndexSplit.cpp
index a66526e..4d4de9d 100644
--- a/lib/Transforms/Scalar/LoopIndexSplit.cpp
+++ b/lib/Transforms/Scalar/LoopIndexSplit.cpp
@@ -13,8 +13,8 @@
#define DEBUG_TYPE "loop-index-split"
-#include "llvm/Function.h"
#include "llvm/Transforms/Scalar.h"
+#include "llvm/Function.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/ScalarEvolutionExpander.h"
#include "llvm/Support/Compiler.h"
@@ -83,6 +83,9 @@ namespace {
// This compare instruction compares IndVar against SplitValue.
ICmpInst *SplitCondition;
+
+ // Loop exit condition.
+ ICmpInst *ExitCondition;
};
char LoopIndexSplit::ID = 0;
@@ -228,7 +231,7 @@ bool LoopIndexSplit::processOneIterationLoop(LPPassManager &LPM) {
// c1 = icmp uge i32 SplitValue, StartValue
// c2 = icmp ult i32 vSplitValue, ExitValue
// and i32 c1, c2
- bool SignedPredicate = SplitCondition->isSignedPredicate();
+ bool SignedPredicate = ExitCondition->isSignedPredicate();
Instruction *C1 = new ICmpInst(SignedPredicate ?
ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE,
SplitValue, StartValue, "lisplit", Terminator);
@@ -303,7 +306,6 @@ bool LoopIndexSplit::safeHeader(BasicBlock *Header) {
// loop may not be eliminated. This is used by processOneIterationLoop().
bool LoopIndexSplit::safeExitBlock(BasicBlock *ExitBlock) {
- Instruction *ExitCondition = NULL;
Instruction *IndVarIncrement = NULL;
for (BasicBlock::iterator BI = ExitBlock->begin(), BE = ExitBlock->end();
@@ -339,11 +341,11 @@ bool LoopIndexSplit::safeExitBlock(BasicBlock *ExitBlock) {
// I is an Exit condition if next instruction is block terminator.
// Exit condition is OK if it compares loop invariant exit value,
// which is checked below.
- else if (isa<ICmpInst>(I)) {
+ else if (ICmpInst *EC = dyn_cast<ICmpInst>(I)) {
++BI;
Instruction *N = BI;
if (N == ExitBlock->getTerminator()) {
- ExitCondition = I;
+ ExitCondition = EC;
break;
}
}