[polly] r248674 - Create parallel code in a separate block

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 26 13:58:00 PDT 2015


Author: jdoerfert
Date: Sat Sep 26 15:57:59 2015
New Revision: 248674

URL: http://llvm.org/viewvc/llvm-project?rev=248674&view=rev
Log:
Create parallel code in a separate block

  This commit basically reverts r246427 but still solves the issue
  tackled by that commit. Instead of emitting initialization code in the
  beginning of the start block we now generate parallel code in its own
  block and thereby guarantee separation. This is necessary as we cannot
  generate code for hoisted loads prior to the start block but it still
  needs to be placed prior to everything else.

Modified:
    polly/trunk/lib/CodeGen/BlockGenerators.cpp
    polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
    polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll
    polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll
    polly/trunk/test/Isl/CodeGen/phi_loop_carried_float.ll
    polly/trunk/test/Isl/CodeGen/phi_loop_carried_float_escape.ll
    polly/trunk/test/Isl/CodeGen/phi_scalar_simple_1.ll
    polly/trunk/test/Isl/CodeGen/phi_scalar_simple_2.ll

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=248674&r1=248673&r2=248674&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Sat Sep 26 15:57:59 2015
@@ -484,7 +484,7 @@ void BlockGenerator::createScalarInitial
   if (StartBB == R.getEntry())
     StartBB = SplitBBTerm->getSuccessor(1);
 
-  Builder.SetInsertPoint(StartBB->begin());
+  Builder.SetInsertPoint(StartBB->getTerminator());
 
   for (auto &Pair : S.arrays()) {
     auto &Array = Pair.second;

Modified: polly/trunk/lib/CodeGen/IslNodeBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslNodeBuilder.cpp?rev=248674&r1=248673&r2=248674&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslNodeBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslNodeBuilder.cpp Sat Sep 26 15:57:59 2015
@@ -534,6 +534,14 @@ void IslNodeBuilder::createForParallel(_
   Value *IV;
   CmpInst::Predicate Predicate;
 
+  // The preamble of parallel code interacts different than normal code with
+  // e.g., scalar initialization. Therefore, we ensure the parallel code is
+  // separated from the last basic block.
+  BasicBlock *ParBB =
+      SplitBlock(Builder.GetInsertBlock(), Builder.GetInsertPoint(), &DT, &LI);
+  ParBB->setName("polly.parallel.for");
+  Builder.SetInsertPoint(ParBB->begin());
+
   Body = isl_ast_node_for_get_body(For);
   Init = isl_ast_node_for_get_init(For);
   Inc = isl_ast_node_for_get_inc(For);

Modified: polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll?rev=248674&r1=248673&r2=248674&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll (original)
+++ polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll Sat Sep 26 15:57:59 2015
@@ -14,7 +14,7 @@
 ; AST: for (int c0 = 0; c0 <= 99; c0 += 1)
 ; AST:   Stmt_for_body(c0);
 
-; IR-LABEL: polly.start:
+; IR-LABEL: polly.parallel.for:
 ; IR-NEXT:  %0 = bitcast { float* }* %polly.par.userContext to i8*
 ; IR-NEXT:  call void @llvm.lifetime.start(i64 8, i8* %0)
 ; IR-NEXT:  %1 = getelementptr inbounds { float* }, { float* }* %polly.par.userContext, i32 0, i32 0

Modified: polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll?rev=248674&r1=248673&r2=248674&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll (original)
+++ polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll Sat Sep 26 15:57:59 2015
@@ -30,7 +30,7 @@
 ; IR-NEXT: entry
 ; IR-NEXT:   %polly.par.userContext = alloca
 
-; IR-LABEL: polly.start:
+; IR-LABEL: polly.parallel.for:
 ; IR-NEXT:   %0 = bitcast {}* %polly.par.userContext to i8*
 ; IR-NEXT:   call void @llvm.lifetime.start(i64 0, i8* %0)
 ; IR-NEXT:   %polly.par.userContext1 = bitcast {}* %polly.par.userContext to i8*

Modified: polly/trunk/test/Isl/CodeGen/phi_loop_carried_float.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/phi_loop_carried_float.ll?rev=248674&r1=248673&r2=248674&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/phi_loop_carried_float.ll (original)
+++ polly/trunk/test/Isl/CodeGen/phi_loop_carried_float.ll Sat Sep 26 15:57:59 2015
@@ -17,6 +17,7 @@
 ; CHECK-NEXT:    ret
 
 ; CHECK-LABEL: polly.start:
+; CHECK-NEXT:    sext
 ; CHECK-NEXT:    store float 0.000000e+00, float* %tmp.0.phiops
 
 ; CHECK-LABEL: polly.merge2:

Modified: polly/trunk/test/Isl/CodeGen/phi_loop_carried_float_escape.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/phi_loop_carried_float_escape.ll?rev=248674&r1=248673&r2=248674&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/phi_loop_carried_float_escape.ll (original)
+++ polly/trunk/test/Isl/CodeGen/phi_loop_carried_float_escape.ll Sat Sep 26 15:57:59 2015
@@ -16,6 +16,7 @@
 ; 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:

Modified: polly/trunk/test/Isl/CodeGen/phi_scalar_simple_1.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/phi_scalar_simple_1.ll?rev=248674&r1=248673&r2=248674&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/phi_scalar_simple_1.ll (original)
+++ polly/trunk/test/Isl/CodeGen/phi_scalar_simple_1.ll Sat Sep 26 15:57:59 2015
@@ -26,7 +26,7 @@ entry:
 ; CHECK:         ret i32 %x.addr.0.merge
 
 ; CHECK-LABEL: polly.start:
-; CHECK-NEXT:    store i32 %x, i32* %x.addr.0.phiops
+; CHECK:         store i32 %x, i32* %x.addr.0.phiops
 
 ; CHECK-LABEL: polly.merge:
 ; CHECK:         %x.addr.0.final_reload = load i32, i32* %x.addr.0.s2a

Modified: polly/trunk/test/Isl/CodeGen/phi_scalar_simple_2.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/phi_scalar_simple_2.ll?rev=248674&r1=248673&r2=248674&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/phi_scalar_simple_2.ll (original)
+++ polly/trunk/test/Isl/CodeGen/phi_scalar_simple_2.ll Sat Sep 26 15:57:59 2015
@@ -28,6 +28,7 @@ entry:
 ; CHECK:         ret i32 %x.addr.0.merge
 
 ; CHECK-LABEL: polly.start:
+; CHECK-NEXT:    sext
 ; CHECK-NEXT:    store i32 %x, i32* %x.addr.0.phiops
 
 ; CHECK-LABEL: polly.merge21:




More information about the llvm-commits mailing list