From 8d438858c8946d4be168202d304ac7dbeaf8b1b8 Mon Sep 17 00:00:00 2001 From: Zhou Sheng Date: Wed, 27 Jun 2007 09:50:26 +0000 Subject: Fix a bug. llvm-svn: 37751 --- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index f0019052d8f..01b74815f52 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -519,8 +519,11 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { DOUT << "INDVARS: New CanIV: " << *IndVar; if (!isa(IterationCount)) { - if (IterationCount->getType() != LargestType) + if (IterationCount->getType()->getPrimitiveSizeInBits() < + LargestType->getPrimitiveSizeInBits()) IterationCount = SCEVZeroExtendExpr::get(IterationCount, LargestType); + else if (IterationCount->getType() != LargestType) + IterationCount = SCEVTruncateExpr::get(IterationCount, LargestType); if (Instruction *DI = LinearFunctionTestReplace(L, IterationCount,Rewriter)) DeadInsts.insert(DI); } -- cgit v1.2.3