llvm-project/polly/test/Isl/CodeGen/simple_non_single_entry.ll

73 lines
1.4 KiB
LLVM
Raw Normal View History

; RUN: opt %loadPolly -polly-codegen -analyze < %s | FileCheck %s
; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s -check-prefix=CHECK-CODE
; void f(long A[], long N) {
; long i;
;
; if (true){
; i = 0;
; goto next;
; }else{
; i = 1;
; goto next;
; }
;
; next:
; if (true)
; goto for.i;
; else
; goto for.i;
;
; for.i:
; for (i = 0; i < N; ++i)
; A[i] = i;
; }
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
define void @f(i64* %A, i64 %N) nounwind {
entry:
fence seq_cst
br i1 true, label %then1, label %else1
then1:
br label %next
else1:
br label %next
next:
%sg = getelementptr i64, i64* %A, i64 42
store i64 undef, i64* %sg
br i1 true, label %then, label %else
then:
br label %for.i.head
else:
br label %for.i.head
for.i.head:
br label %for.i.head1
for.i.head1:
br label %for.i
for.i:
%indvar = phi i64 [ 0, %for.i.head1], [ %indvar.next, %for.i ]
fence seq_cst
%scevgep = getelementptr i64, i64* %A, i64 %indvar
store i64 %indvar, i64* %scevgep
%indvar.next = add nsw i64 %indvar, 1
%exitcond = icmp eq i64 %indvar.next, %N
br i1 %exitcond, label %return, label %for.i
return:
fence seq_cst
ret void
}
Revise the simplification of regions The previous code had several problems: For newly created BasicBlocks it did not (always) call RegionInfo::setRegionFor in order to update its analysis. At the moment RegionInfo does not verify its BBMap, but will in the future. This is fixed by determining the region new BBs belong to and set it accordingly. The new executeScopConditionally() requires accurate getRegionFor information. Which block is created by SplitEdge depends on the incoming and outgoing edges of the blocks it connects, which makes handling its output more difficult than it needs to be. Especially for finding which block has been created an to assign a region to it for the setRegionFor problem above. This patch uses an implementation for splitEdge that always creates a block between the predecessor and successor. simplifyRegion has also been simplified by using SplitBlockPredecessors instead of SplitEdge. Isolating the entries and exits have been refectored into individual functions. Previously simplifyRegion did more than just ensuring that there is only one entering and one exiting edge. It ensured that the entering block had no other outgoing edge which was necessary for executeScopConditionally(). Now the latter uses the alternative splitEdge implementation which can handle this situation so simplifyRegion really only needs to simplify the region. Also, executeScopConditionally assumed that there can be no PHI nodes in blocks with one incoming edge. This is wrong and LCSSA deliberately produces such edges. However, previous passes ensured that there can be no such PHIs in exit nodes, but which will no longer hold in the future. The new code that the property that it preserves the identity of region block (the property that the memory address of the BasicBlock containing the instructions remains the same; new blocks only contain PHI nodes and a terminator), especially the entry block. As a result, there is no need to update the reference to the BasicBlock of ScopStmt that contain its instructions because they have been moved to other basic blocks. Reviewers: grosser Part of Differential Revision: http://reviews.llvm.org/D11867 llvm-svn: 244606
2015-08-11 22:39:21 +08:00
; CHECK: Create LLVM-IR from SCoPs' for region: 'next => polly.merge_new_and_old'
; CHECK-CODE: polly.split_new_and_old
; CHECK-CODE: polly.merge_new_and_old