2015-10-06 23:36:44 +08:00
|
|
|
; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s -check-prefix=SEQUENTIAL
|
|
|
|
; RUN: opt %loadPolly -polly-codegen -polly-ast-detect-parallel -S < %s | FileCheck %s -check-prefix=PARALLEL
|
2014-03-04 22:59:00 +08:00
|
|
|
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-n8:16:32:64"
|
|
|
|
|
|
|
|
; This is a trivially parallel loop. We just use it to ensure that we actually
|
|
|
|
; emit the right information.
|
|
|
|
;
|
|
|
|
; for (i = 0; i < n; i++)
|
|
|
|
; A[i] = 1;
|
|
|
|
;
|
|
|
|
@A = common global [1024 x i32] zeroinitializer
|
|
|
|
define void @test-one(i64 %n) {
|
|
|
|
start:
|
|
|
|
fence seq_cst
|
|
|
|
br label %loop.header
|
|
|
|
|
|
|
|
loop.header:
|
|
|
|
%i = phi i64 [ 0, %start ], [ %i.next, %loop.backedge ]
|
|
|
|
%exitcond = icmp ne i64 %i, %n
|
|
|
|
br i1 %exitcond, label %loop.body, label %ret
|
|
|
|
|
|
|
|
loop.body:
|
2015-02-28 03:20:19 +08:00
|
|
|
%scevgep = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %i
|
2014-03-04 22:59:00 +08:00
|
|
|
store i32 1, i32* %scevgep
|
|
|
|
br label %loop.backedge
|
|
|
|
|
|
|
|
loop.backedge:
|
|
|
|
%i.next = add nsw i64 %i, 1
|
|
|
|
br label %loop.header
|
|
|
|
|
|
|
|
ret:
|
|
|
|
fence seq_cst
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; SEQUENTIAL: @test-one
|
|
|
|
; SEQUENTIAL-NOT: !llvm.mem.parallel_loop_access
|
2014-10-02 23:31:24 +08:00
|
|
|
; SEQUENTIAL-NOT: !llvm.loop
|
2014-03-04 22:59:00 +08:00
|
|
|
|
|
|
|
; PARALLEL: @test-one
|
2014-11-30 22:33:31 +08:00
|
|
|
; PARALLEL: store i32 1, i32* %scevgep1, {{[ ._!,a-zA-Z0-9]*}}, !llvm.mem.parallel_loop_access ![[LoopID:[0-9]*]]
|
2014-10-02 23:31:24 +08:00
|
|
|
; PARALLEL: br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit, !llvm.loop ![[LoopID]]
|
2014-03-04 22:59:00 +08:00
|
|
|
|
|
|
|
; This loop has memory dependences that require at least a simple dependence
|
|
|
|
; analysis to detect the parallelism.
|
|
|
|
;
|
|
|
|
; for (i = 0; i < n; i++)
|
|
|
|
; A[2 * i] = A[2 * i + 1];
|
|
|
|
;
|
|
|
|
define void @test-two(i64 %n) {
|
|
|
|
start:
|
|
|
|
fence seq_cst
|
|
|
|
br label %loop.header
|
|
|
|
|
|
|
|
loop.header:
|
|
|
|
%i = phi i64 [ 0, %start ], [ %i.next, %loop.backedge ]
|
|
|
|
%exitcond = icmp ne i64 %i, %n
|
|
|
|
br i1 %exitcond, label %loop.body, label %ret
|
|
|
|
|
|
|
|
loop.body:
|
|
|
|
%loadoffset1 = mul nsw i64 %i, 2
|
|
|
|
%loadoffset2 = add nsw i64 %loadoffset1, 1
|
2015-02-28 03:20:19 +08:00
|
|
|
%scevgepload = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %loadoffset2
|
2015-02-28 05:22:50 +08:00
|
|
|
%val = load i32, i32* %scevgepload
|
2014-03-04 22:59:00 +08:00
|
|
|
%storeoffset = mul i64 %i, 2
|
2015-02-28 03:20:19 +08:00
|
|
|
%scevgepstore = getelementptr [1024 x i32], [1024 x i32]* @A, i64 0, i64 %storeoffset
|
2014-03-04 22:59:00 +08:00
|
|
|
store i32 %val, i32* %scevgepstore
|
|
|
|
br label %loop.backedge
|
|
|
|
|
|
|
|
loop.backedge:
|
|
|
|
%i.next = add nsw i64 %i, 1
|
|
|
|
br label %loop.header
|
|
|
|
|
|
|
|
ret:
|
|
|
|
fence seq_cst
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; SEQUENTIAL: @test-two
|
|
|
|
; SEQUENTIAL-NOT: !llvm.mem.parallel_loop_access
|
2014-10-02 23:31:24 +08:00
|
|
|
; SEQUENTIAL-NOT: !llvm.loop
|
2014-03-04 22:59:00 +08:00
|
|
|
|
|
|
|
; PARALLEL: @test-two
|
2015-02-28 05:22:50 +08:00
|
|
|
; PARALLEL: %val_p_scalar_ = load i32, i32* %scevgep, {{[ ._!,a-zA-Z0-9]*}}, !llvm.mem.parallel_loop_access ![[LoopID:[0-9]*]]
|
2014-11-30 22:33:31 +08:00
|
|
|
; PARALLEL: store i32 %val_p_scalar_, i32* %scevgep1, {{[ ._!,a-zA-Z0-9]*}}, !llvm.mem.parallel_loop_access ![[LoopID]]
|
|
|
|
; PARALLEL: br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit, !llvm.loop ![[LoopID]]
|