use the canonical IV only when it exists
llvm-svn: 177306
diff --git a/polly/lib/CodeGen/CodeGeneration.cpp b/polly/lib/CodeGen/CodeGeneration.cpp
index ebe6e7e..f71e931 100644
--- a/polly/lib/CodeGen/CodeGeneration.cpp
+++ b/polly/lib/CodeGen/CodeGeneration.cpp
@@ -370,24 +370,26 @@
unsigned Dim, int VectorDim,
std::vector<ValueMapT> *VectorVMap,
std::vector<LoopToScevMapT> *VLTS) {
- const PHINode *PN;
Value *RHS;
assert(!A->LHS && "Statement assignments do not have left hand side");
- PN = Stmt->getInductionVariableForDimension(Dim);
RHS = ExpGen.codegen(A->RHS, Builder.getInt64Ty());
- RHS = Builder.CreateTruncOrBitCast(RHS, PN->getType());
-
- if (VectorVMap)
- (*VectorVMap)[VectorDim][PN] = RHS;
const llvm::SCEV *URHS = S->getSE()->getUnknown(RHS);
if (VLTS)
(*VLTS)[VectorDim][Stmt->getLoopForDimension(Dim)] = URHS;
-
- ValueMap[PN] = RHS;
LoopToScev[Stmt->getLoopForDimension(Dim)] = URHS;
+
+ const PHINode *PN = Stmt->getInductionVariableForDimension(Dim);
+ if (PN) {
+ RHS = Builder.CreateTruncOrBitCast(RHS, PN->getType());
+
+ if (VectorVMap)
+ (*VectorVMap)[VectorDim][PN] = RHS;
+
+ ValueMap[PN] = RHS;
+ }
}
void ClastStmtCodeGen::codegenSubstitutions(