Update Polly tests to handle explicitly typed gep changes in LLVM
[polly-mirror.git] / test / Isl / CodeGen / OpenMP / single_loop.ll
blob9a1fa5d2b889df6a219f70fc6f00943668735c40
1 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-parallel -polly-parallel-force -polly-ast -analyze < %s | FileCheck %s -check-prefix=AST
2 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-parallel -polly-parallel-force -polly-codegen-isl -S -verify-dom-info < %s | FileCheck %s -check-prefix=IR
3 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-parallel -polly-parallel-force -polly-codegen-isl -S -verify-dom-info < %s | FileCheck %s -check-prefix=IR
5 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-parallel -polly-parallel-force -polly-import-jscop -polly-import-jscop-dir=%S -polly-ast -analyze < %s | FileCheck %s -check-prefix=AST-STRIDE4
6 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-parallel -polly-parallel-force -polly-import-jscop -polly-import-jscop-dir=%S -polly-codegen-isl -S < %s | FileCheck %s -check-prefix=IR-STRIDE4
7 ; RUN: opt %loadPolly -polly-detect-unprofitable -polly-parallel -polly-parallel-force -polly-import-jscop -polly-import-jscop-dir=%S -polly-codegen-isl -S < %s | FileCheck %s -check-prefix=IR-STRIDE4
9 ; This extensive test case tests the creation of the full set of OpenMP calls
10 ; as well as the subfunction creation using a trivial loop as example.
12 ; #define N 1024
13 ; float A[N];
15 ; void single_parallel_loop(void) {
16 ;   for (long i = 0; i < N; i++)
17 ;     A[i] = 1;
18 ; }
20 ; AST: #pragma simd
21 ; AST: #pragma omp parallel for
22 ; AST: for (int c0 = 0; c0 <= 1023; c0 += 1)
23 ; AST:   Stmt_S(c0);
25 ; AST-STRIDE4: #pragma omp parallel for
26 ; AST-STRIDE4: for (int c0 = 0; c0 <= 1023; c0 += 4)
27 ; AST-STRIDE4:   #pragma simd
28 ; AST-STRIDE4:   for (int c1 = c0; c1 <= c0 + 3; c1 += 1)
29 ; AST-STRIDE4:     Stmt_S(c1);
31 ; IR-LABEL: single_parallel_loop()
32 ; IR-NEXT: entry
33 ; IR-NEXT:   %polly.par.userContext = alloca
35 ; IR-LABEL: polly.start:
36 ; IR-NEXT:   %0 = bitcast {}* %polly.par.userContext to i8*
37 ; IR-NEXT:   call void @llvm.lifetime.start(i64 0, i8* %0)
38 ; IR-NEXT:   %polly.par.userContext1 = bitcast {}* %polly.par.userContext to i8*
39 ; IR-NEXT:   call void @GOMP_parallel_loop_runtime_start(void (i8*)* @single_parallel_loop.polly.subfn, i8* %polly.par.userContext1, i32 0, i64 0, i64 1024, i64 1)
40 ; IR-NEXT:   call void @single_parallel_loop.polly.subfn(i8* %polly.par.userContext1)
41 ; IR-NEXT:   call void @GOMP_parallel_end()
42 ; IR-NEXT:   %1 = bitcast {}* %polly.par.userContext to i8*
43 ; IR-NEXT:   call void @llvm.lifetime.end(i64 8, i8* %1)
44 ; IR-NEXT:   br label %polly.merge_new_and_old
46 ; IR: define internal void @single_parallel_loop.polly.subfn(i8* %polly.par.userContext) #1
47 ; IR-LABEL: polly.par.setup:
48 ; IR-NEXT:   %polly.par.LBPtr = alloca i64
49 ; IR-NEXT:   %polly.par.UBPtr = alloca i64
50 ; IR-NEXT:   %polly.par.userContext1 =
51 ; IR:   br label %polly.par.checkNext
53 ; IR-LABEL: polly.par.exit:
54 ; IR-NEXT:   call void @GOMP_loop_end_nowait()
55 ; IR-NEXT:   ret void
57 ; IR-LABEL: polly.par.checkNext:
58 ; IR-NEXT:   %[[parnext:[._a-zA-Z0-9]*]] = call i8 @GOMP_loop_runtime_next(i64* %polly.par.LBPtr, i64* %polly.par.UBPtr)
59 ; IR-NEXT:   %[[cmp:[._a-zA-Z0-9]*]] = icmp ne i8 %[[parnext]], 0
60 ; IR-NEXT:   br i1 %[[cmp]], label %polly.par.loadIVBounds, label %polly.par.exit
62 ; IR-LABEL: polly.par.loadIVBounds:
63 ; IR-NEXT:   %polly.par.LB = load i64* %polly.par.LBPtr
64 ; IR-NEXT:   %polly.par.UB = load i64* %polly.par.UBPtr
65 ; IR-NEXT:   %polly.par.UBAdjusted = sub i64 %polly.par.UB, 1
66 ; IR-NEXT:   br label %polly.loop_preheader
68 ; IR-LABEL: polly.loop_exit:
69 ; IR-NEXT:   br label %polly.par.checkNext
71 ; IR-LABEL: polly.loop_header:
72 ; IR-NEXT:   %polly.indvar = phi i64 [ %polly.par.LB, %polly.loop_preheader ], [ %polly.indvar_next, %polly.stmt.S ]
73 ; IR-NEXT:   br label %polly.stmt.S
75 ; IR-LABEL: polly.stmt.S:
76 ; IR-NEXT:   %[[gep:[._a-zA-Z0-9]*]] = getelementptr [1024 x float], [1024 x float]* {{.*}}, i64 0, i64 %polly.indvar
77 ; IR-NEXT:   store float 1.000000e+00, float* %[[gep]]
78 ; IR-NEXT:   %polly.indvar_next = add nsw i64 %polly.indvar, 1
79 ; IR-NEXT:   %polly.adjust_ub = sub i64 %polly.par.UBAdjusted, 1
80 ; IR-NEXT:   %polly.loop_cond = icmp sle i64 %polly.indvar, %polly.adjust_ub
81 ; IR-NEXT:   br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
83 ; IR-LABEL: polly.loop_preheader:
84 ; IR-NEXT:   br label %polly.loop_header
86 ; IR: attributes #1 = { "polly.skip.fn" }
88 ; IR-STRIDE4:   call void @GOMP_parallel_loop_runtime_start(void (i8*)* @single_parallel_loop.polly.subfn, i8* %polly.par.userContext1, i32 0, i64 0, i64 1024, i64 4)
89 ; IR-STRIDE4:  add nsw i64 %polly.indvar, 3
90 ; IR-STRIDE4:  %polly.indvar_next = add nsw i64 %polly.indvar, 4
91 ; IR-STRIDE4   %polly.adjust_ub = sub i64 %polly.par.UBAdjusted, 4
93 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"
94 target triple = "x86_64-unknown-linux-gnu"
96 @A = common global [1024 x float] zeroinitializer, align 16
98 define void @single_parallel_loop() nounwind {
99 entry:
100   br label %for.i
102 for.i:
103   %indvar = phi i64 [ %indvar.next, %for.inc], [ 0, %entry ]
104   %scevgep = getelementptr [1024 x float], [1024 x float]* @A, i64 0, i64 %indvar
105   %exitcond = icmp ne i64 %indvar, 1024
106   br i1 %exitcond, label %S, label %exit
109   store float 1.0, float* %scevgep
110   br label %for.inc
112 for.inc:
113   %indvar.next = add i64 %indvar, 1
114   br label %for.i
116 exit:
117   ret void