Index: polly/trunk/lib/Analysis/ScopInfo.cpp =================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp +++ polly/trunk/lib/Analysis/ScopInfo.cpp @@ -3604,7 +3604,13 @@ InstStmtMap.erase(&Inst); } } else { - StmtMap.erase(Stmt.getBasicBlock()); + auto StmtMapIt = StmtMap.find(Stmt.getBasicBlock()); + if (StmtMapIt != StmtMap.end()) + StmtMapIt->second.erase(std::remove(StmtMapIt->second.begin(), + StmtMapIt->second.end(), &Stmt), + StmtMapIt->second.end()); + for (Instruction *Inst : Stmt.getInstructions()) + InstStmtMap.erase(Inst); } } Index: polly/trunk/lib/Support/VirtualInstruction.cpp =================================================================== --- polly/trunk/lib/Support/VirtualInstruction.cpp +++ polly/trunk/lib/Support/VirtualInstruction.cpp @@ -78,7 +78,7 @@ // A use is inter-statement if either it is defined in another statement, or // there is a MemoryAccess that reads its value that has been written by // another statement. - if (InputMA || (!Virtual && !UserStmt->represents(Inst->getParent()))) + if (InputMA || (!Virtual && UserStmt != S->getStmtFor(Inst))) return VirtualUse(UserStmt, Val, Inter, nullptr, InputMA); return VirtualUse(UserStmt, Val, Intra, nullptr, nullptr); Index: polly/trunk/test/ScopInfo/stmt_split_no_after_split.ll =================================================================== --- polly/trunk/test/ScopInfo/stmt_split_no_after_split.ll +++ polly/trunk/test/ScopInfo/stmt_split_no_after_split.ll @@ -0,0 +1,43 @@ +; RUN: opt %loadPolly -polly-scops -analyze -polly-print-instructions < %s | FileCheck %s +; +; CHECK: Statements { +; CHECK-NEXT: Stmt_Stmt +; CHECK-NEXT: Domain := +; CHECK-NEXT: { Stmt_Stmt[i0] : 0 <= i0 <= 1023 }; +; CHECK-NEXT: Schedule := +; CHECK-NEXT: { Stmt_Stmt[i0] -> [i0] }; +; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT: { Stmt_Stmt[i0] -> MemRef_A[i0] }; +; CHECK-NEXT: Instructions { +; CHECK-NEXT: store i32 %i.0, i32* %arrayidx, align 4, !polly_split_after !0 +; CHECK-NEXT: } +; CHECK-NEXT: } +; +; Function Attrs: noinline nounwind uwtable +define void @func(i32* %A) #0 { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %i.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ] + %cmp = icmp slt i32 %i.0, 1024 + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + br label %Stmt + +Stmt: + %idxprom = sext i32 %i.0 to i64 + %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom + store i32 %i.0, i32* %arrayidx, align 4, !polly_split_after !0 + br label %for.inc + +for.inc: ; preds = %Stmt + %add = add nsw i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} + +!0 = !{!"polly_split_after"} Index: polly/trunk/test/ScopInfo/stmt_split_scalar_dependence.ll =================================================================== --- polly/trunk/test/ScopInfo/stmt_split_scalar_dependence.ll +++ polly/trunk/test/ScopInfo/stmt_split_scalar_dependence.ll @@ -0,0 +1,60 @@ +; RUN: opt %loadPolly -polly-scops -analyze -polly-print-instructions < %s | FileCheck %s +; +; CHECK: Statements { +; CHECK-NEXT: Stmt_Stmt +; CHECK-NEXT: Domain := +; CHECK-NEXT: { Stmt_Stmt[i0] : 0 <= i0 <= 1023 }; +; CHECK-NEXT: Schedule := +; CHECK-NEXT: { Stmt_Stmt[i0] -> [i0, 0] }; +; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT: { Stmt_Stmt[i0] -> MemRef_A[i0] }; +; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 1] +; CHECK-NEXT: { Stmt_Stmt[i0] -> MemRef_a[] }; +; CHECK-NEXT: Instructions { +; CHECK-NEXT: %a = fadd double 2.100000e+01, 2.100000e+01 +; CHECK-NEXT: store i32 %i.0, i32* %arrayidx, align 4, !polly_split_after !0 +; CHECK-NEXT: } +; CHECK-NEXT: Stmt_Stmt1 +; CHECK-NEXT: Domain := +; CHECK-NEXT: { Stmt_Stmt1[i0] : 0 <= i0 <= 1023 }; +; CHECK-NEXT: Schedule := +; CHECK-NEXT: { Stmt_Stmt1[i0] -> [i0, 1] }; +; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT: { Stmt_Stmt1[i0] -> MemRef_B[0] }; +; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 1] +; CHECK-NEXT: { Stmt_Stmt1[i0] -> MemRef_a[] }; +; CHECK-NEXT: Instructions { +; CHECK-NEXT: store double %a, double* %B +; CHECK-NEXT: } +; CHECK-NEXT: } +; +; Function Attrs: noinline nounwind uwtable +define void @func(i32* %A, double* %B) #0 { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %i.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ] + %cmp = icmp slt i32 %i.0, 1024 + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + br label %Stmt + +Stmt: + %a = fadd double 21.0, 21.0 + %idxprom = sext i32 %i.0 to i64 + %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom + store i32 %i.0, i32* %arrayidx, align 4, !polly_split_after !0 + store double %a, double* %B + br label %for.inc + +for.inc: ; preds = %Stmt + %add = add nsw i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} + +!0 = !{!"polly_split_after"}