[polly] r177306 - use the canonical IV only when it exists

Sebastian Pop spop at codeaurora.org
Mon Mar 18 12:09:49 PDT 2013


Author: spop
Date: Mon Mar 18 14:09:49 2013
New Revision: 177306

URL: http://llvm.org/viewvc/llvm-project?rev=177306&view=rev
Log:
use the canonical IV only when it exists

Modified:
    polly/trunk/lib/CodeGen/CodeGeneration.cpp
    polly/trunk/lib/CodeGen/IslCodeGeneration.cpp

Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=177306&r1=177305&r2=177306&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Mon Mar 18 14:09:49 2013
@@ -370,24 +370,26 @@ void ClastStmtCodeGen::codegen(const cla
                                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(

Modified: polly/trunk/lib/CodeGen/IslCodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslCodeGeneration.cpp?rev=177306&r1=177305&r2=177306&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslCodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/IslCodeGeneration.cpp Mon Mar 18 14:09:49 2013
@@ -891,21 +891,23 @@ void IslNodeBuilder::createSubstitutions
   for (unsigned i = 0; i < isl_pw_multi_aff_dim(PMA, isl_dim_out); ++i) {
     isl_pw_aff *Aff;
     isl_ast_expr *Expr;
-    const Value *OldIV;
     Value *V;
 
     Aff = isl_pw_multi_aff_get_pw_aff(PMA, i);
     Expr = isl_ast_build_expr_from_pw_aff(Context, Aff);
-    OldIV = Stmt->getInductionVariableForDimension(i);
     V = ExprBuilder.create(Expr);
 
+    ScalarEvolution *SE = Stmt->getParent()->getSE();
+    LTS[Stmt->getLoopForDimension(i)] = SE->getUnknown(V);
+
     // CreateIntCast can introduce trunc expressions. This is correct, as the
     // result will always fit into the type of the original induction variable
     // (because we calculate a value of the original induction variable).
-    V = Builder.CreateIntCast(V, OldIV->getType(), true);
-    VMap[OldIV] = V;
-    ScalarEvolution *SE = Stmt->getParent()->getSE();
-    LTS[Stmt->getLoopForDimension(i)] = SE->getUnknown(V);
+    const Value *OldIV = Stmt->getInductionVariableForDimension(i);
+    if (OldIV) {
+      V = Builder.CreateIntCast(V, OldIV->getType(), true);
+      VMap[OldIV] = V;
+    }
   }
 
   isl_pw_multi_aff_free(PMA);





More information about the llvm-commits mailing list