diff options
author | Tobias Grosser <tobias@grosser.es> | 2015-12-09 11:38:22 +0000 |
---|---|---|
committer | Tobias Grosser <tobias@grosser.es> | 2015-12-09 11:38:22 +0000 |
commit | 2d3d4ec860ff13494aaf56855dbe05bf1ab68a29 (patch) | |
tree | 7e5b0a5e3d83967225b572c26c4b459a197e8e7d | |
parent | 87a44d29a2ab3a94220dc6fcfb1de0e41a68817d (diff) | |
download | bcm5719-llvm-2d3d4ec860ff13494aaf56855dbe05bf1ab68a29.tar.gz bcm5719-llvm-2d3d4ec860ff13494aaf56855dbe05bf1ab68a29.zip |
executeScopConditionally: Introduce special exiting block
When introducing separate control flow for the original and optimized code we
introduce now a special 'ExitingBlock':
\ /
EnteringBB
|
SplitBlock---------\
_____|_____ |
/ EntryBB \ StartBlock
| (region) | |
\_ExitingBB_/ ExitingBlock
| |
MergeBlock---------/
|
ExitBB
/ \
This 'ExitingBlock' contains code such as the final_reloads for scalars, which
previously were just added to whichever statement/loop_exit/branch-merge block
had been generated last. Having an explicit basic block makes it easier to
find these constructs when looking at the CFG.
llvm-svn: 255107
17 files changed, 38 insertions, 27 deletions
diff --git a/polly/lib/CodeGen/Utils.cpp b/polly/lib/CodeGen/Utils.cpp index dd6b162ccb0..743a0cceec0 100644 --- a/polly/lib/CodeGen/Utils.cpp +++ b/polly/lib/CodeGen/Utils.cpp @@ -141,17 +141,23 @@ BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) { // 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 // @@ -159,16 +165,21 @@ BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) { // 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); @@ -179,7 +190,7 @@ BasicBlock *polly::executeScopConditionally(Scop &S, Pass *P, Value *RTC) { // _____|_____ | // // / EntryBB \ StartBlock // // | (region) | | // - // \_ExitingBB_/ | // + // \_ExitingBB_/ ExitingBlock // // | | // // MergeBlock---------/ // // | // diff --git a/polly/test/Isl/CodeGen/OpenMP/single_loop.ll b/polly/test/Isl/CodeGen/OpenMP/single_loop.ll index 454e815ec49..f43d1c395a3 100644 --- a/polly/test/Isl/CodeGen/OpenMP/single_loop.ll +++ b/polly/test/Isl/CodeGen/OpenMP/single_loop.ll @@ -39,7 +39,7 @@ ; 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: diff --git a/polly/test/Isl/CodeGen/invariant_load_escaping.ll b/polly/test/Isl/CodeGen/invariant_load_escaping.ll index 5afa1a6bc80..56918bfa54d 100644 --- a/polly/test/Isl/CodeGen/invariant_load_escaping.ll +++ b/polly/test/Isl/CodeGen/invariant_load_escaping.ll @@ -21,7 +21,7 @@ ; 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: diff --git a/polly/test/Isl/CodeGen/out-of-scop-phi-node-use.ll b/polly/test/Isl/CodeGen/out-of-scop-phi-node-use.ll index 1c5780985f2..65d6090560e 100644 --- a/polly/test/Isl/CodeGen/out-of-scop-phi-node-use.ll +++ b/polly/test/Isl/CodeGen/out-of-scop-phi-node-use.ll @@ -4,12 +4,12 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 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 diff --git a/polly/test/Isl/CodeGen/phi-defined-before-scop.ll b/polly/test/Isl/CodeGen/phi-defined-before-scop.ll index f684dcca63b..1567117946e 100644 --- a/polly/test/Isl/CodeGen/phi-defined-before-scop.ll +++ b/polly/test/Isl/CodeGen/phi-defined-before-scop.ll @@ -1,7 +1,7 @@ ; 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 diff --git a/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_2.ll b/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_2.ll index ab71ae3a286..939b8a79fa9 100644 --- a/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_2.ll +++ b/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_2.ll @@ -7,12 +7,12 @@ ; 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) { diff --git a/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_3.ll b/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_3.ll index 138d204f762..45a765b9035 100644 --- a/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_3.ll +++ b/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_3.ll @@ -4,7 +4,7 @@ ; 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 ] diff --git a/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_5.ll b/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_5.ll index 03ad2f4ebf9..bbf62e4f620 100644 --- a/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_5.ll +++ b/polly/test/Isl/CodeGen/phi_in_exit_early_lnt_failure_5.ll @@ -4,7 +4,7 @@ ; 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: diff --git a/polly/test/Isl/CodeGen/phi_loop_carried_float.ll b/polly/test/Isl/CodeGen/phi_loop_carried_float.ll index f191279ae2c..cfcdb58d7df 100644 --- a/polly/test/Isl/CodeGen/phi_loop_carried_float.ll +++ b/polly/test/Isl/CodeGen/phi_loop_carried_float.ll @@ -20,7 +20,7 @@ ; 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]*}}: diff --git a/polly/test/Isl/CodeGen/phi_loop_carried_float_escape.ll b/polly/test/Isl/CodeGen/phi_loop_carried_float_escape.ll index 11d3697202a..cce111282e9 100644 --- a/polly/test/Isl/CodeGen/phi_loop_carried_float_escape.ll +++ b/polly/test/Isl/CodeGen/phi_loop_carried_float_escape.ll @@ -12,14 +12,14 @@ ; } ; 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 diff --git a/polly/test/Isl/CodeGen/phi_scalar_simple_1.ll b/polly/test/Isl/CodeGen/phi_scalar_simple_1.ll index 3e1623d0537..c39b24f7caf 100644 --- a/polly/test/Isl/CodeGen/phi_scalar_simple_1.ll +++ b/polly/test/Isl/CodeGen/phi_scalar_simple_1.ll @@ -22,7 +22,7 @@ entry: 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: diff --git a/polly/test/Isl/CodeGen/phi_scalar_simple_2.ll b/polly/test/Isl/CodeGen/phi_scalar_simple_2.ll index 6d69cb68642..f0812fea1f3 100644 --- a/polly/test/Isl/CodeGen/phi_scalar_simple_2.ll +++ b/polly/test/Isl/CodeGen/phi_scalar_simple_2.ll @@ -24,7 +24,7 @@ entry: 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: diff --git a/polly/test/Isl/CodeGen/phi_with_multi_exiting_edges_2.ll b/polly/test/Isl/CodeGen/phi_with_multi_exiting_edges_2.ll index bffb329b7b1..dd02de10865 100644 --- a/polly/test/Isl/CodeGen/phi_with_multi_exiting_edges_2.ll +++ b/polly/test/Isl/CodeGen/phi_with_multi_exiting_edges_2.ll @@ -1,7 +1,7 @@ ; 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: diff --git a/polly/test/Isl/CodeGen/phi_with_one_exit_edge.ll b/polly/test/Isl/CodeGen/phi_with_one_exit_edge.ll index f4a0500b962..129e0ffbdb6 100644 --- a/polly/test/Isl/CodeGen/phi_with_one_exit_edge.ll +++ b/polly/test/Isl/CodeGen/phi_with_one_exit_edge.ll @@ -2,7 +2,7 @@ ; ; ; 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: diff --git a/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll b/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll index cb9ac0a4382..f74efa90fcd 100644 --- a/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll +++ b/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_escaping.ll @@ -50,8 +50,8 @@ ; 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 diff --git a/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_same_pointer_escaping.ll b/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_same_pointer_escaping.ll index 8213fb4afd3..fa5a4aab772 100644 --- a/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_same_pointer_escaping.ll +++ b/polly/test/ScopInfo/invariant_load_access_classes_different_base_type_same_pointer_escaping.ll @@ -40,8 +40,8 @@ ; 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 diff --git a/polly/test/ScopInfo/out-of-scop-use-in-region-entry-phi-node-nonaffine-subregion.ll b/polly/test/ScopInfo/out-of-scop-use-in-region-entry-phi-node-nonaffine-subregion.ll index 66a15bef510..224da09a989 100755 --- a/polly/test/ScopInfo/out-of-scop-use-in-region-entry-phi-node-nonaffine-subregion.ll +++ b/polly/test/ScopInfo/out-of-scop-use-in-region-entry-phi-node-nonaffine-subregion.ll @@ -7,7 +7,7 @@ ; 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 |