[ScopBuilder/Simplify] Refactor isEscaping. NFC.
[polly-mirror.git] / test / ScopInfo / int2ptr_ptr2int_2.ll
blob3fc64d41675a0f44e24469c816a62b1ad8af3364
1 ; RUN: opt %loadPolly -analyze -polly-scops \
2 ; RUN: -polly-invariant-load-hoisting=true < %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);
10 ;        A[ptrV] += B[valP];
11 ;      }
12 ;    }
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] -> {  : val <= 9223372036854775806 }
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] };
23 ; IR:      polly.stmt.for.body:
24 ; IR-NEXT:  %p_tmp = ptrtoint i64* %scevgep to i64
25 ; IR-NEXT:  %p_add = add nsw i64 %p_tmp, 1
26 ; IR-NEXT:  %p_arrayidx3 = getelementptr inbounds i64, i64* %A, i64 %p_add
27 ; IR-NEXT:  %tmp4_p_scalar_ = load i64, i64* %p_arrayidx3
28 ; IR-NEXT:  %p_add4 = add nsw i64 %tmp4_p_scalar_, %polly.preload.tmp3.merge
29 ; IR-NEXT:  store i64 %p_add4, i64* %p_arrayidx3
31 ; IR:      polly.loop_preheader:
32 ; IR-NEXT:   %scevgep = getelementptr i64, i64* %ptr, i64 1
33 ; IR-NEXT:   %26 = add i64 %val, 1
34 ; IR-NEXT:   br label %polly.loop_header
37 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
39 define void @f(i64* %A, i64* %B, i64* %ptr, i64 %val) {
40 entry:
41   br label %for.cond
43 for.cond:                                         ; preds = %for.inc, %entry
44   %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
45   %exitcond = icmp ne i64 %i.0, 100
46   br i1 %exitcond, label %for.body, label %for.end
48 for.body:                                         ; preds = %for.cond
49   %add.ptr = getelementptr inbounds i64, i64* %ptr, i64 1
50   %tmp = ptrtoint i64* %add.ptr to i64
51   %add = add nsw i64 %tmp, 1
52   %add1 = add nsw i64 %val, 1
53   %tmp1 = inttoptr i64 %add1 to i64*
54   %add.ptr2 = getelementptr inbounds i64, i64* %tmp1, i64 1
55   %tmp2 = ptrtoint i64* %add.ptr2 to i64
56   %arrayidx = getelementptr inbounds i64, i64* %B, i64 %tmp2
57   %tmp3 = load i64, i64* %arrayidx
58   %arrayidx3 = getelementptr inbounds i64, i64* %A, i64 %add
59   %tmp4 = load i64, i64* %arrayidx3
60   %add4 = add nsw i64 %tmp4, %tmp3
61   store i64 %add4, i64* %arrayidx3
62   br label %for.inc
64 for.inc:                                          ; preds = %for.body
65   %inc = add nuw nsw i64 %i.0, 1
66   br label %for.cond
68 for.end:                                          ; preds = %for.cond
69   ret void