1 ; RUN: opt %loadNPMPolly '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 | FileCheck %s
2 ; RUN: opt %loadNPMPolly -S -passes=polly-codegen < %s 2>&1 | FileCheck %s --check-prefix=IR
4 ; void f(long *A, long *ptr, long val) {
5 ; for (long i = 0; i < 100; i++) {
6 ; long ptrV = ((long)(ptr + 1)) + 1;
7 ; long valP = (long)(((long *)(val + 1)) + 1);
12 ; CHECK: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
13 ; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + val] };
14 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
15 ; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] };
16 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
17 ; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] };
20 ; IR-NEXT: %ptr1 = ptrtoint ptr %ptr to i32
22 ; IR: polly.stmt.for.body:
23 ; IR-NEXT: %p_tmp1 = inttoptr i64 %14 to ptr
24 ; IR-NEXT: %p_add.ptr2 = getelementptr inbounds i64, ptr %p_tmp1, i64 1
25 ; IR-NEXT: %p_tmp2 = ptrtoint ptr %p_add.ptr2 to i64
26 ; IR-NEXT: %p_arrayidx = getelementptr inbounds i64, ptr %A, i64 %p_tmp2
27 ; IR-NEXT: %tmp3_p_scalar_ = load i64, ptr %p_arrayidx, align 8, !alias.scope !0, !noalias !3
28 ; IR-NEXT: %tmp4_p_scalar_ = load i64, ptr %scevgep, align 8, !alias.scope !0, !noalias !3
29 ; IR-NEXT: %p_add4 = add nsw i64 %tmp4_p_scalar_, %tmp3_p_scalar_
30 ; IR-NEXT: store i64 %p_add4, ptr %scevgep, align 8, !alias.scope !0, !noalias !3
31 ; IR-NEXT: %polly.indvar_next = add nsw i64 %polly.indvar, 1
32 ; IR-NEXT: %polly.loop_cond = icmp sle i64 %polly.indvar_next, 99
33 ; IR-NEXT: br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
35 ; IR: polly.loop_preheader:
36 ; IR-NEXT: %14 = add i64 %val, 1
37 ; IR-NEXT: %15 = shl i32 %ptr1, 3
38 ; IR-NEXT: %16 = add i32 %15, 72
39 ; IR-NEXT: %scevgep = getelementptr i8, ptr %A, i32 %16
40 ; IR-NEXT: br label %polly.loop_header
43 target datalayout = "e-p:32:32:32-m:e-i64:64-f80:128-n8:16:32:64-S128"
45 define void @f(ptr %A, ptr %ptr, i64 %val) {
49 for.cond: ; preds = %for.inc, %entry
50 %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
51 %exitcond = icmp ne i64 %i.0, 100
52 br i1 %exitcond, label %for.body, label %for.end
54 for.body: ; preds = %for.cond
55 %add.ptr = getelementptr inbounds i64, ptr %ptr, i64 1
56 %tmp = ptrtoint ptr %add.ptr to i64
57 %add = add nsw i64 %tmp, 1
58 %add1 = add nsw i64 %val, 1
59 %tmp1 = inttoptr i64 %add1 to ptr
60 %add.ptr2 = getelementptr inbounds i64, ptr %tmp1, i64 1
61 %tmp2 = ptrtoint ptr %add.ptr2 to i64
62 %arrayidx = getelementptr inbounds i64, ptr %A, i64 %tmp2
63 %tmp3 = load i64, ptr %arrayidx
64 %arrayidx3 = getelementptr inbounds i64, ptr %A, i64 %add
65 %tmp4 = load i64, ptr %arrayidx3
66 %add4 = add nsw i64 %tmp4, %tmp3
67 store i64 %add4, ptr %arrayidx3
70 for.inc: ; preds = %for.body
71 %inc = add nuw nsw i64 %i.0, 1
74 for.end: ; preds = %for.cond