// ExitBB //
// / \ //
- // Create the start block.
+ // Create the start and exiting block.
Function *F = SplitBlock->getParent();
BasicBlock *StartBlock =
BasicBlock::Create(F->getContext(), "polly.start", F);
+ BasicBlock *ExitingBlock =
+ BasicBlock::Create(F->getContext(), "polly.exiting", F);
SplitBlock->getTerminator()->eraseFromParent();
Builder.SetInsertPoint(SplitBlock);
Builder.CreateCondBr(RTC, StartBlock, R.getEntry());
- if (Loop *L = LI.getLoopFor(SplitBlock))
+ if (Loop *L = LI.getLoopFor(SplitBlock)) {
L->addBasicBlockToLoop(StartBlock, LI);
+ L->addBasicBlockToLoop(ExitingBlock, LI);
+ }
DT.addNewBlock(StartBlock, SplitBlock);
+ DT.addNewBlock(ExitingBlock, StartBlock);
RI.setRegionFor(StartBlock, RI.getRegionFor(SplitBlock));
+ RI.setRegionFor(ExitingBlock, RI.getRegionFor(SplitBlock));
// \ / //
// EnteringBB //
// SplitBlock---------\ //
// _____|_____ | //
// / EntryBB \ StartBlock //
- // | (region) | //
- // \_ExitingBB_/ //
+ // | (region) | | //
+ // \_ExitingBB_/ ExitingBlock //
// | //
// MergeBlock //
// | //
// ExitBB //
// / \ //
- // Connect start block to the join block.
+ // Connect start block to exiting block.
Builder.SetInsertPoint(StartBlock);
+ Builder.CreateBr(ExitingBlock);
+ DT.changeImmediateDominator(ExitingBlock, StartBlock);
+
+ // Connect exiting block to join block.
+ Builder.SetInsertPoint(ExitingBlock);
Builder.CreateBr(MergeBlock);
DT.changeImmediateDominator(MergeBlock, SplitBlock);
// _____|_____ | //
// / EntryBB \ StartBlock //
// | (region) | | //
- // \_ExitingBB_/ | //
+ // \_ExitingBB_/ ExitingBlock //
// | | //
// MergeBlock---------/ //
// | //
; IR-NEXT: call void @GOMP_parallel_end()
; IR-NEXT: %1 = bitcast {}* %polly.par.userContext to i8*
; IR-NEXT: call void @llvm.lifetime.end(i64 8, i8* %1)
-; IR-NEXT: br label %polly.merge_new_and_old
+; IR-NEXT: br label %polly.exiting
; IR: define internal void @single_parallel_loop_polly_subfn(i8* %polly.par.userContext) #2
; IR-LABEL: polly.par.setup:
; CHECK: store i32 %polly.access.B.load, i32* %tmp.preload.s2a
;
; CHECK: polly.merge_new_and_old:
-; CHECK: %tmp.merge = phi i32 [ %tmp.final_reload, %polly.loop_exit ], [ %tmp, %do.cond ]
+; CHECK: %tmp.merge = phi i32 [ %tmp.final_reload, %polly.exiting ], [ %tmp, %do.cond ]
; CHECK: br label %do.end
;
; CHECK: do.end:
target triple = "x86_64-unknown-linux-gnu"
; CHECK-LABEL: polly.merge_new_and_old:
-; CHECK-NEXT: %_s.sroa.343.0.ph5161118.ph.merge = phi i32 [ %_s.sroa.343.0.ph5161118.ph.final_reload, %polly.stmt.polly.merge_new_and_old.exit ], [ %_s.sroa.343.0.ph516.lcssa2357, %for.cond.981.region_exiting ]
+; CHECK-NEXT: %_s.sroa.343.0.ph5161118.ph.merge = phi i32 [ %_s.sroa.343.0.ph5161118.ph.final_reload, %polly.exiting ], [ %_s.sroa.343.0.ph516.lcssa2357, %for.cond.981.region_exiting ]
; CHECK-LABEL: for.cond.981:
; CHECK-NEXT: %_s.sroa.343.0.ph5161118 = phi i32 [ undef, %for.cond ], [ %_s.sroa.343.0.ph5161118.ph.merge, %polly.merge_new_and_old ]
-; CHECK-LABEL: polly.stmt.polly.merge_new_and_old.exit:
+; CHECK-LABEL: polly.exiting:
; CHECK-NEXT: %_s.sroa.343.0.ph5161118.ph.final_reload = load i32, i32* %_s.sroa.343.0.ph5161118.s2a
; Function Attrs: nounwind uwtable
; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
; CHECK-LABEL: polly.merge_new_and_old:
-; CHECK-NEXT: %tmp7.ph.merge = phi %struct.wibble* [ %tmp7.ph.final_reload, %polly.stmt.bb5 ], [ %tmp7.ph, %bb6.region_exiting ]
+; CHECK-NEXT: %tmp7.ph.merge = phi %struct.wibble* [ %tmp7.ph.final_reload, %polly.exiting ], [ %tmp7.ph, %bb6.region_exiting ]
; CHECK-LABEL: polly.stmt.bb3:
; CHECK-NEXT: %tmp2.s2a.reload = load %struct.wibble*, %struct.wibble** %tmp2.s2a
; CHECK-NOT: %eps1.addr.0.ph.s2a = alloca double
;
; CHECK-LABEL: polly.merge_new_and_old:
-; CHECK: %eps1.addr.0.ph.merge = phi double [ %eps1.addr.0.ph.final_reload, %polly.stmt.if.end.47.region_exiting.exit ], [ %eps1.addr.0.ph, %if.end.47.region_exiting ]
+; CHECK: %eps1.addr.0.ph.merge = phi double [ %eps1.addr.0.ph.final_reload, %polly.exiting ], [ %eps1.addr.0.ph, %if.end.47.region_exiting ]
;
; CHECK-LABEL: polly.start:
; CHECK-NEXT: store double %eps1, double* %eps1.s2a
;
-; CHECK-LABEL: polly.stmt.if.end.47.region_exiting.exit:
+; CHECK-LABEL: polly.exiting:
; CHECK-NEXT: %eps1.addr.0.ph.final_reload = load double, double* %eps1.addr.0.s2a
;
define void @dbisect(double* %c, double* %b, double %eps1, double* %eps2) {
; produce the PHI node in the exit we are looking for.
;
; CHECK-LABEL: polly.merge_new_and_old:
-; CHECK-NEXT: %n2ptr.2.ph.merge = phi i8* [ %n2ptr.2.ph.final_reload, %polly.merge ], [ %n2ptr.2.ph, %if.end.45.region_exiting ]
+; CHECK-NEXT: %n2ptr.2.ph.merge = phi i8* [ %n2ptr.2.ph.final_reload, %polly.exiting ], [ %n2ptr.2.ph, %if.end.45.region_exiting ]
;
; CHECK-LABEL: if.end.45:
; CHECK-NEXT: %n2ptr.2 = phi i8* [ %add.ptr25, %entry ], [ %add.ptr25, %while.cond.preheader ], [ %n2ptr.2.ph.merge, %polly.merge_new_and_old ]
; produce the PHI node in the exit we are looking for.
;
; CHECK-LABEL: polly.merge_new_and_old:
-; CHECK-NEXT: %eps1.addr.0.ph.merge = phi double [ %eps1.addr.0.ph.final_reload, %polly.stmt.if.end.47.region_exiting.exit ], [ %eps1.addr.0.ph, %if.end.47.region_exiting ]
+; CHECK-NEXT: %eps1.addr.0.ph.merge = phi double [ %eps1.addr.0.ph.final_reload, %polly.exiting ], [ %eps1.addr.0.ph, %if.end.47.region_exiting ]
; CHECK-NEXT: br label %if.end.47
;
; CHECK-LABEL: if.end.47:
; CHECK-NEXT: sext
; CHECK-NEXT: store float 0.000000e+00, float* %tmp.0.phiops
-; CHECK-LABEL: polly.merge2:
+; CHECK-LABEL: polly.exiting:
; CHECK-NEXT: br label %polly.merge_new_and_old
; CHECK-LABEL: polly.stmt.bb1{{[0-9]*}}:
; }
; CHECK-LABEL: polly.merge_new_and_old:
-; CHECK-NEXT: %tmp.0.merge = phi float [ %tmp.0.final_reload, %polly.merge2 ], [ %tmp.0, %bb8 ]
+; CHECK-NEXT: %tmp.0.merge = phi float [ %tmp.0.final_reload, %polly.exiting ], [ %tmp.0, %bb8 ]
; CHECK-NEXT: br label %exit
; CHECK-LABEL: polly.start:
; CHECK-NEXT: sext
; CHECK-NEXT: store float 0.000000e+00, float* %tmp.0.phiops
-; CHECK-LABEL: polly.merge2:
+; CHECK-LABEL: polly.exiting:
; CHECK-NEXT: %tmp.0.final_reload = load float, float* %tmp.0.s2a
; CHECK-NEXT: br label %polly.merge_new_and_old
br label %for.cond
; CHECK-LABEL: polly.merge_new_and_old:
-; CHECK: %x.addr.0.merge = phi i32 [ %x.addr.0.final_reload, %polly.merge ], [ %x.addr.0, %for.cond ]
+; CHECK: %x.addr.0.merge = phi i32 [ %x.addr.0.final_reload, %polly.exiting ], [ %x.addr.0, %for.cond ]
; CHECK: ret i32 %x.addr.0.merge
; CHECK-LABEL: polly.start:
br label %for.cond
; CHECK-LABEL: polly.merge_new_and_old:
-; CHECK: %x.addr.0.merge = phi i32 [ %x.addr.0.final_reload, %polly.merge21 ], [ %x.addr.0, %for.cond ]
+; CHECK: %x.addr.0.merge = phi i32 [ %x.addr.0.final_reload, %polly.exiting ], [ %x.addr.0, %for.cond ]
; CHECK: ret i32 %x.addr.0.merge
; CHECK-LABEL: polly.start:
; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
;
; CHECK: polly.merge_new_and_old:
-; CHECK: %result.ph.merge = phi float [ %result.ph.final_reload, %polly.merge ], [ %result.ph, %next.region_exiting ]
+; CHECK: %result.ph.merge = phi float [ %result.ph.final_reload, %polly.exiting ], [ %result.ph, %next.region_exiting ]
; CHECK: br label %next
;
; CHECK: next:
;
;
; CHECK: polly.merge_new_and_old:
-; CHECK: %sumA.merge = phi float [ %sumA.final_reload, %polly.loop_exit ], [ %sumA, %loopA ]
+; CHECK: %sumA.merge = phi float [ %sumA.final_reload, %polly.exiting ], [ %sumA, %loopA ]
; CHECK: br label %next
;
; CHECK: next:
; CODEGEN: store float %.load12, float* %S.b.preload.s2a
;
; CODEGEN: polly.merge_new_and_old:
-; CODEGEN-DAG: %S.b.merge = phi float [ %S.b.final_reload, %polly.loop_exit ], [ %S.b, %do.cond ]
-; CODEGEN-DAG: %S.a.merge = phi i32 [ %S.a.final_reload, %polly.loop_exit ], [ %S.a, %do.cond ]
+; CODEGEN-DAG: %S.b.merge = phi float [ %S.b.final_reload, %polly.exiting ], [ %S.b, %do.cond ]
+; CODEGEN-DAG: %S.a.merge = phi i32 [ %S.a.final_reload, %polly.exiting ], [ %S.a, %do.cond ]
;
; CODEGEN: do.end:
; CODEGEN: %conv3 = sitofp i32 %S.a.merge to float
; CODEGEN: store float %U.load1, float* %U.f.preload.s2a
;
; CODEGEN: polly.merge_new_and_old:
-; CODEGEN-DAG: %U.f.merge = phi float [ %U.f.final_reload, %polly.loop_exit ], [ %U.f, %do.cond ]
-; CODEGEN-DAG: %U.i.merge = phi i32 [ %5, %polly.loop_exit ], [ %U.i, %do.cond ]
+; CODEGEN-DAG: %U.f.merge = phi float [ %U.f.final_reload, %polly.exiting ], [ %U.f, %do.cond ]
+; CODEGEN-DAG: %U.i.merge = phi i32 [ %5, %polly.exiting ], [ %U.i, %do.cond ]
;
; CODEGEN: polly.loop_exit:
; CODEGEN-DAG: %U.f.final_reload = load float, float* %U.f.preload.s2a
; CHECK: %loop_carried.ph = phi float [ %newval.merge, %backedge ], [ undef, %entry ]
;
; CHECK-LABEL: polly.merge_new_and_old:
-; CHECK: %newval.merge = phi float [ %newval.final_reload, %polly.stmt.polly.merge_new_and_old.exit ], [ %newval, %subregion_exit.region_exiting ]
+; CHECK: %newval.merge = phi float [ %newval.final_reload, %polly.exiting ], [ %newval, %subregion_exit.region_exiting ]
;
; CHECK-LABEL: polly.start:
; CHECK: store float %loop_carried.ph, float* %loop_carried.phiops