1 ; RUN: opt %loadPolly -analyze -polly-scops \
2 ; RUN: -polly-detect-fortran-arrays \
3 ; RUN: -polly-invariant-load-hoisting \
4 ; RUN: -polly-use-llvm-names \
5 ; RUN: -polly-stmt-granularity=bb \
6 ; RUN: < %s | FileCheck %s --check-prefix=SCOP
8 ; RUN: opt %loadPolly -S \
9 ; RUN: -polly-detect-fortran-arrays \
10 ; RUN: -polly-codegen-ppcg \
11 ; RUN: -polly-invariant-load-hoisting \
12 ; RUN: -polly-use-llvm-names \
13 ; RUN: -polly-acc-fail-on-verify-module-failure \
14 ; RUN: < %s | FileCheck %s --check-prefix=HOST-IR
18 ; In Polly, we specifically add a parameter to represent the outermost dimension
19 ; size of fortran arrays. We do this because this information is statically
20 ; available from the fortran metadata generated by dragonegg.
21 ; However, we were only materializing these parameters (meaning, creating an
22 ; llvm::Value to back the isl_id) from *memory accesses*. This is wrong,
23 ; we should materialize parameters from *scop array info*.
25 ; It is wrong because if there is a case where we detect 2 fortran arrays,
26 ; but only one of them is accessed, we may not materialize the other array's
29 ; This test case checks that we do not fail if there is an array that does
30 ; not have an access (In this case, `memory`), we still generate the
33 ; Check that we detect the function as a Scop.
35 ; SCOP-NEXT: Region: %loop.prepare---%for.exit
36 ; SCOP-NEXT: Max Loop Depth: 1
38 ; Check that we detect fortran arrays.
39 ; SCOP: Arrays (Bounds as pw_affs) {
40 ; SCOP: double* MemRef_global_arr[*]; // Element size 8
41 ; SCOP-NEXT: double MemRef_memory[ [MemRef_memory_fortranarr_size] -> { [] -> [(MemRef_memory_fortranarr_size)] } ]; [BasePtrOrigin: MemRef_global_arr] // Element size 8
42 ; SCOP-NEXT: double MemRef_memory2[ [MemRef_memory2_fortranarr_size] -> { [] -> [(MemRef_memory2_fortranarr_size)] } ]; [BasePtrOrigin: MemRef_global_arr] // Element size 8
45 ; Check that we have writes *only* into memory2, not into memory.
48 ; SCOP: MustWriteAccess := [Reduction Type: NONE] [Fortran array descriptor: global_arr] [Scalar: 0]
49 ; SCOP-NEXT: [start_val, end_val, offset, MemRef_memory_fortranarr_size, MemRef_memory2_fortranarr_size] -> { Stmt_for_body[i0] -> MemRef_memory2[start_val + offset + i0] };
50 ; SCOP-NEXT: ReadAccess := [Reduction Type: NONE] [Fortran array descriptor: global_arr] [Scalar: 0]
51 ; SCOP-NEXT: [start_val, end_val, offset, MemRef_memory_fortranarr_size, MemRef_memory2_fortranarr_size] -> { Stmt_for_body[i0] -> MemRef_memory2[start_val + offset + i0] };
54 ; Check that we materialize the sizes and send it across to the kernel.
55 ; HOST-IR: store i64 %MemRef_memory_size, i64* %polly_launch_0_param_4
56 ; HOST-IR: store i64 %MemRef_memory2_size, i64* %polly_launch_0_param_5
57 target datalayout = "e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
58 target triple = "x86_64-unknown-linux-gnu"
60 module asm "\09.ident\09\22GCC: (GNU) 4.6.4 LLVM: 3.3.1\22"
62 %"struct.array1_real(kind=8)" = type { i8*, i64, i64, [1 x %struct.descriptor_dimension] }
63 %struct.descriptor_dimension = type { i64, i64, i64 }
65 @global_arr = external unnamed_addr global %"struct.array1_real(kind=8)", align 32
67 ; Function Attrs: nounwind uwtable
68 define void @f(i32* noalias %ipstart, i32* noalias %ipend) unnamed_addr #0 {
70 br label %loop.prepare
73 loop.prepare: ; preds = %"6", %"3.preheader"
74 %start.val = load i32, i32* %ipstart, align 4
75 %end.val = load i32, i32* %ipend, align 4
76 %should.loop = icmp sgt i32 %start.val, %end.val
77 br i1 %should.loop, label %for.exit, label %for.body
80 for.body: ; preds = %for.body, %"4.preheader"
81 %i = phi i32 [ %i.next, %for.body ], [ %start.val, %loop.prepare ]
82 %i.sext = sext i32 %i to i64
83 %memory = load double*, double** bitcast (%"struct.array1_real(kind=8)"* @global_arr to double**), align 32
84 %offset = load i64, i64* getelementptr inbounds (%"struct.array1_real(kind=8)", %"struct.array1_real(kind=8)"* @global_arr, i64 0, i32 1), align 8
85 %idx = add i64 %offset, %i.sext
86 %slot = getelementptr double, double* %memory, i64 %idx
87 store double 1.0, double* %slot, align 8
89 %memory2 = load double*, double** bitcast (%"struct.array1_real(kind=8)"* @global_arr to double**), align 32
90 %offset2 = load i64, i64* getelementptr inbounds (%"struct.array1_real(kind=8)", %"struct.array1_real(kind=8)"* @global_arr, i64 0, i32 1), align 8
91 %idx2 = add i64 %offset2, %i.sext
92 %slot2 = getelementptr double, double* %memory2, i64 %idx2
93 %val = load double, double* %slot2, align 8
95 %should.loopexit = icmp eq i32 %i, %end.val
96 %i.next = add i32 %i, 1
97 br i1 %should.loopexit, label %for.exit, label %for.body
99 for.exit: ; preds = %for.body
103 attributes #0 = { nounwind uwtable }