1 ; RUN: opt %loadPolly -polly-detect-unprofitable -S -polly-codegen-isl -polly-code-generator=isl -polly-delinearize < %s | FileCheck %s
3 ; Check that we calculate the maximal access into array A correctly.
5 ; CHECK: %[[TMP0:[._0-9a-zA-Z]*]] = mul i64 99, %m
6 ; CHECK: %[[TMP1:[._0-9a-zA-Z]*]] = add i64 %[[TMP0]], 149
7 ; CHECK: %[[TMP2:[._0-9a-zA-Z]*]] = mul i64 %[[TMP1]], %p
8 ; CHECK: %[[TMP3:[._0-9a-zA-Z]*]] = add i64 %[[TMP2]], 150
9 ; CHECK: %polly.access.A{{[0-9]*}} = getelementptr double, double* %A, i64 %[[TMP3]]
11 ; void foo(long n, long m, long p, double A[n][m][p], int *B) {
12 ; for (long i = 0; i < 100; i++)
13 ; for (long j = 0; j < 150; j++)
14 ; for (long k = 0; k < 150; k++)
18 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20 define void @foo(i64 %n, i64 %m, i64 %p, double* %A, i32* %B) {
24 for.cond: ; preds = %for.inc03, %entry
25 %i.0 = phi i64 [ 0, %entry ], [ %inc04, %for.inc03 ]
26 %exitcond2 = icmp ne i64 %i.0, 100
27 br i1 %exitcond2, label %for.body, label %for.end15
29 for.body: ; preds = %for.cond
32 for.cond1: ; preds = %for.inc00, %for.body
33 %j.0 = phi i64 [ 0, %for.body ], [ %inc01, %for.inc00 ]
34 %exitcond1 = icmp ne i64 %j.0, 150
35 br i1 %exitcond1, label %for.body3, label %for.end12
37 for.body3: ; preds = %for.cond1
40 for.cond4: ; preds = %for.inc, %for.body3
41 %k.0 = phi i64 [ 0, %for.body3 ], [ %inc, %for.inc ]
42 %exitcond = icmp ne i64 %k.0, 150
43 br i1 %exitcond, label %for.body6, label %for.end
45 for.body6: ; preds = %for.cond4
46 %arrayidx = getelementptr inbounds i32, i32* %B, i64 %k.0
47 %tmp3 = load i32* %arrayidx, align 2
48 %conv = sitofp i32 %tmp3 to double
49 %tmp4 = mul nuw i64 %m, %p
50 %tmp5 = mul nsw i64 %i.0, %tmp4
51 %tmp6 = mul nsw i64 %j.0, %p
52 %arrayidx7.sum = add i64 %tmp5, %tmp6
53 %arrayidx8.sum = add i64 %arrayidx7.sum, %k.0
54 %arrayidx9 = getelementptr inbounds double, double* %A, i64 %arrayidx8.sum
55 store double %conv, double* %arrayidx9, align 8
58 for.inc: ; preds = %for.body6
59 %inc = add nsw i64 %k.0, 1
62 for.end: ; preds = %for.cond4
65 for.inc00: ; preds = %for.end
66 %inc01 = add nsw i64 %j.0, 1
69 for.end12: ; preds = %for.cond1
72 for.inc03: ; preds = %for.end12
73 %inc04 = add nsw i64 %i.0, 1
76 for.end15: ; preds = %for.cond