[polly] r252726 - ScopDetection: Tighten the check for always executed 'error blocks'

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 09:31:44 PST 2015


We should not go for dominance at all but for post-dominance instead and
use it to compute control conditions (see below). Hence, if the
(immediate) control condition of a error block is a conditional we should
consider it to be an error block, otherwise not.

Below:
- copied from https://www.cs.utexas.edu/~pingali/CS380C/2013/lectures/Dominators.pdf

Control dependence: given a CFG G, a node w is control-dependent on an edge (u -> v) if
  – w postdominates v
  – w does not strictly postdominate u


On 11/11, Tobias Grosser via llvm-commits wrote:
> Author: grosser
> Date: Wed Nov 11 07:25:13 2015
> New Revision: 252726
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=252726&view=rev
> Log:
> ScopDetection: Tighten the check for always executed 'error blocks'
> 
> Basic blocks that are always executed can not be error blocks as their execution
> can not possibly be an unlikely event. In this commit we tighten the check
> if an error block to basic blcoks that do not dominate the exit condition, but
> that dominate all exiting blocks of the scop.
> 
> Added:
>     polly/trunk/test/ScopDetect/error-block-always-executed.ll
> Modified:
>     polly/trunk/lib/Support/ScopHelper.cpp
> 
> Modified: polly/trunk/lib/Support/ScopHelper.cpp
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/ScopHelper.cpp?rev=252726&r1=252725&r2=252726&view=diff
> ==============================================================================
> --- polly/trunk/lib/Support/ScopHelper.cpp (original)
> +++ polly/trunk/lib/Support/ScopHelper.cpp Wed Nov 11 07:25:13 2015
> @@ -352,7 +352,14 @@ bool polly::isErrorBlock(BasicBlock &BB,
>    if (LI.isLoopHeader(&BB))
>      return false;
>  
> -  if (DT.dominates(&BB, R.getExit()))
> +  // Basic blocks that are always executed are not considered error blocks,
> +  // as their execution can not be a rare event.
> +  bool DominatesAllPredecessors = true;
> +  for (auto Pred : predecessors(R.getExit()))
> +    if (R.contains(Pred) && !DT.dominates(&BB, Pred))
> +      DominatesAllPredecessors = false;
> +
> +  if (DominatesAllPredecessors)
>      return false;
>  
>    // FIXME: This is a simple heuristic to determine if the load is executed
> 
> Added: polly/trunk/test/ScopDetect/error-block-always-executed.ll
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopDetect/error-block-always-executed.ll?rev=252726&view=auto
> ==============================================================================
> --- polly/trunk/test/ScopDetect/error-block-always-executed.ll (added)
> +++ polly/trunk/test/ScopDetect/error-block-always-executed.ll Wed Nov 11 07:25:13 2015
> @@ -0,0 +1,62 @@
> +; RUN: opt %loadPolly -polly-code-generator=isl -polly-detect -analyze < %s \
> +; RUN:     | FileCheck %s
> +;
> +; CHECK-NOT: Valid Region for Scop:
> +
> +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> +target triple = "x86_64-unknown-linux-gnu"
> +
> +%struct.hoge = type { i32, i32, i32, i32 }
> +
> +; Function Attrs: nounwind uwtable
> +define void @widget() #0 {
> +bb13:
> +  %tmp1 = alloca %struct.hoge, align 4
> +  br i1 undef, label %bb14, label %bb19
> +
> +bb14:                                             ; preds = %bb13
> +  %tmp = load i32, i32* undef, align 4, !tbaa !1
> +  call void @quux() #2
> +  br i1 false, label %bb15, label %bb18
> +
> +bb15:                                             ; preds = %bb14
> +  %tmp16 = getelementptr inbounds %struct.hoge, %struct.hoge* %tmp1, i64 0, i32 1
> +  %tmp17 = getelementptr inbounds %struct.hoge, %struct.hoge* %tmp1, i64 0, i32 2
> +  br label %bb19
> +
> +bb18:                                             ; preds = %bb14
> +  br label %bb19
> +
> +bb19:                                             ; preds = %bb18, %bb15, %bb13
> +  %tmp20 = phi i32 [ undef, %bb13 ], [ %tmp, %bb15 ], [ %tmp, %bb18 ]
> +  unreachable
> +
> +bb21:                                             ; preds = %bb8
> +  unreachable
> +
> +bb22:                                             ; preds = %bb8, %bb8, %bb8, %bb8
> +  br label %bb23
> +
> +bb23:                                             ; preds = %bb22
> +  unreachable
> +
> +bb24:                                             ; preds = %bb8, %bb8
> +  unreachable
> +
> +bb25:                                             ; preds = %bb2
> +  unreachable
> +}
> +
> +declare void @quux() #1
> +
> +attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
> +attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
> +attributes #2 = { nounwind }
> +
> +!llvm.ident = !{!0}
> +
> +!0 = !{!"clang version 3.8.0 (trunk 252700) (llvm/trunk 252705)"}
> +!1 = !{!2, !2, i64 0}
> +!2 = !{!"int", !3, i64 0}
> +!3 = !{!"omnipotent char", !4, i64 0}
> +!4 = !{!"Simple C/C++ TBAA"}
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits

-- 

Johannes Doerfert
Researcher / PhD Student

Compiler Design Lab (Prof. Hack)
Saarland University, Computer Science
Building E1.3, Room 4.31

Tel. +49 (0)681 302-57521 : doerfert at cs.uni-saarland.de
Fax. +49 (0)681 302-3065  : http://www.cdl.uni-saarland.de/people/doerfert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151111/dd8d7e28/attachment.sig>


More information about the llvm-commits mailing list