1 ; RUN: opt %loadPolly -polly-print-scops \
2 ; RUN: -polly-invariant-load-hoisting=true -disable-output < %s | FileCheck %s
3 ; RUN: opt %loadPolly -S -polly-codegen \
4 ; RUN: -polly-invariant-load-hoisting=true < %s | FileCheck %s --check-prefix=IR
6 ; void f(long *A, long *B, long *ptr, long val) {
7 ; for (long i = 0; i < 100; i++) {
8 ; long ptrV = ((long)(ptr + 1)) + 1;
9 ; long valP = (long)(((long *)(val + 1)) + 1);
14 ; CHECK: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
15 ; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_B[9 + val] };
16 ; CHECK-NEXT: Execution Context: [val, ptr] -> { : -4097 <= val <= 4086 }
18 ; CHECK: ReadAccess := [Reduction Type: +] [Scalar: 0]
19 ; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] };
20 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: +] [Scalar: 0]
21 ; CHECK-NEXT: [val, ptr] -> { Stmt_for_body[i0] -> MemRef_A[9 + ptr] };
24 ; IR-NEXT: %ptr13 = ptrtoint ptr %ptr to i16
26 ; IR: polly.stmt.for.body:
27 ; IR-NEXT: %tmp4_p_scalar_ = load i64, ptr %scevgep, align 8, !alias.scope !3, !noalias !0
28 ; IR-NEXT: %p_add4 = add nsw i64 %tmp4_p_scalar_, %polly.preload.tmp3.merge
29 ; IR-NEXT: store i64 %p_add4, ptr %scevgep, align 8, !alias.scope !3, !noalias !0
30 ; IR-NEXT: %polly.indvar_next = add nsw i64 %polly.indvar, 1
31 ; IR-NEXT: %polly.loop_cond = icmp sle i64 %polly.indvar_next, 99
32 ; IR-NEXT: br i1 %polly.loop_cond, label %polly.loop_header, label %polly.loop_exit
34 ; IR: polly.loop_preheader:
35 ; IR-NEXT: %41 = add i16 %val, 1
36 ; IR-NEXT: %42 = shl i16 %ptr13, 3
37 ; IR-NEXT: %43 = add i16 %42, 72
38 ; IR-NEXT: %scevgep = getelementptr i8, ptr %A, i16 %43
39 ; IR-NEXT: br label %polly.loop_header
41 target datalayout = "e-p:16:16:16-m:e-i64:64-f80:128-n8:16:16:64-S128"
43 define void @f(ptr %A, ptr %B, ptr %ptr, i16 %val) {
47 for.cond: ; preds = %for.inc, %entry
48 %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
49 %exitcond = icmp ne i64 %i.0, 100
50 br i1 %exitcond, label %for.body, label %for.end
52 for.body: ; preds = %for.cond
53 %add.ptr = getelementptr inbounds i64, ptr %ptr, i64 1
54 %tmp = ptrtoint ptr %add.ptr to i16
55 %add = add nsw i16 %tmp, 1
56 %add1 = add nsw i16 %val, 1
57 %tmp1 = inttoptr i16 %add1 to ptr
58 %add.ptr2 = getelementptr inbounds i64, ptr %tmp1, i64 1
59 %tmp2 = ptrtoint ptr %add.ptr2 to i16
60 %arrayidx = getelementptr inbounds i64, ptr %B, i16 %tmp2
61 %tmp3 = load i64, ptr %arrayidx
62 %arrayidx3 = getelementptr inbounds i64, ptr %A, i16 %add
63 %tmp4 = load i64, ptr %arrayidx3
64 %add4 = add nsw i64 %tmp4, %tmp3
65 store i64 %add4, ptr %arrayidx3
68 for.inc: ; preds = %for.body
69 %inc = add nuw nsw i64 %i.0, 1
72 for.end: ; preds = %for.cond