1 ; RUN: opt %loadPolly -S -polly-codegen < %s | FileCheck %s
3 ; Check that we calculate the maximal access into array A correctly and track the overflow state.
5 ; CHECK: %[[TMP0:[._0-9a-zA-Z]*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 99, i64 %m)
6 ; CHECK: %[[TMP0O:[._0-9a-zA-Z]*]] = extractvalue { i64, i1 } %[[TMP0]], 1
7 ; CHECK: %[[OS0:[._0-9a-zA-Z]*]] = or i1 {{[^,]*}}, %[[TMP0O]]
8 ; CHECK: %[[TMP0R:[._0-9a-zA-Z]*]] = extractvalue { i64, i1 } %[[TMP0]], 0
9 ; CHECK: %[[TMP1:[._0-9a-zA-Z]*]] = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %[[TMP0R]], i64 149)
10 ; CHECK: %[[TMP1O:[._0-9a-zA-Z]*]] = extractvalue { i64, i1 } %[[TMP1]], 1
11 ; CHECK: %[[OS1:[._0-9a-zA-Z]*]] = or i1 %[[OS0]], %[[TMP1O]]
12 ; CHECK: %[[TMP1R:[._0-9a-zA-Z]*]] = extractvalue { i64, i1 } %[[TMP1]], 0
13 ; CHECK: %[[TMP2:[._0-9a-zA-Z]*]] = call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %[[TMP1R]], i64 %p)
14 ; CHECK: %[[TMP2O:[._0-9a-zA-Z]*]] = extractvalue { i64, i1 } %[[TMP2]], 1
15 ; CHECK: %[[OS2:[._0-9a-zA-Z]*]] = or i1 %[[OS1]], %[[TMP2O]]
16 ; CHECK: %[[TMP2R:[._0-9a-zA-Z]*]] = extractvalue { i64, i1 } %[[TMP2]], 0
17 ; CHECK: %[[TMP3:[._0-9a-zA-Z]*]] = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %[[TMP2R]], i64 150)
18 ; CHECK: %[[TMP3O:[._0-9a-zA-Z]*]] = extractvalue { i64, i1 } %[[TMP3]], 1
19 ; CHECK: %[[OS3:[._0-9a-zA-Z]*]] = or i1 %[[OS2]], %[[TMP3O]]
20 ; CHECK: %[[TMP3R:[._0-9a-zA-Z]*]] = extractvalue { i64, i1 } %[[TMP3]], 0
21 ; CHECK: %polly.access.A{{[0-9]*}} = getelementptr double, ptr %A, i64 %[[TMP3R]]
23 ; CHECK: %polly.rtc.overflown = xor i1 %[[OS3]], true
24 ; CHECK: %polly.rtc.result = and i1 %{{[^,]*}}, %polly.rtc.overflown
25 ; CHECK: br i1 %polly.rtc.result,
27 ; void foo(long n, long m, long p, double A[n][m][p], int *B) {
28 ; for (long i = 0; i < 100; i++)
29 ; for (long j = 0; j < 150; j++)
30 ; for (long k = 0; k < 150; k++)
34 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
36 define void @foo(i64 %n, i64 %m, i64 %p, ptr %A, ptr %B) {
40 for.cond: ; preds = %for.inc03, %entry
41 %i.0 = phi i64 [ 0, %entry ], [ %inc04, %for.inc03 ]
42 %exitcond2 = icmp ne i64 %i.0, 100
43 br i1 %exitcond2, label %for.body, label %for.end15
45 for.body: ; preds = %for.cond
48 for.cond1: ; preds = %for.inc00, %for.body
49 %j.0 = phi i64 [ 0, %for.body ], [ %inc01, %for.inc00 ]
50 %exitcond1 = icmp ne i64 %j.0, 150
51 br i1 %exitcond1, label %for.body3, label %for.end12
53 for.body3: ; preds = %for.cond1
56 for.cond4: ; preds = %for.inc, %for.body3
57 %k.0 = phi i64 [ 0, %for.body3 ], [ %inc, %for.inc ]
58 %exitcond = icmp ne i64 %k.0, 150
59 br i1 %exitcond, label %for.body6, label %for.end
61 for.body6: ; preds = %for.cond4
62 %arrayidx = getelementptr inbounds i32, ptr %B, i64 %k.0
63 %tmp3 = load i32, ptr %arrayidx, align 2
64 %conv = sitofp i32 %tmp3 to double
65 %tmp4 = mul nuw i64 %m, %p
66 %tmp5 = mul nsw i64 %i.0, %tmp4
67 %tmp6 = mul nsw i64 %j.0, %p
68 %arrayidx7.sum = add i64 %tmp5, %tmp6
69 %arrayidx8.sum = add i64 %arrayidx7.sum, %k.0
70 %arrayidx9 = getelementptr inbounds double, ptr %A, i64 %arrayidx8.sum
71 store double %conv, ptr %arrayidx9, align 8
74 for.inc: ; preds = %for.body6
75 %inc = add nsw i64 %k.0, 1
78 for.end: ; preds = %for.cond4
81 for.inc00: ; preds = %for.end
82 %inc01 = add nsw i64 %j.0, 1
85 for.end12: ; preds = %for.cond1
88 for.inc03: ; preds = %for.end12
89 %inc04 = add nsw i64 %i.0, 1
92 for.end15: ; preds = %for.cond