1 ; RUN: opt %loadNPMPolly '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 | FileCheck %s
3 ; We should not generate runtime check for ((int)r1 + (int)r2) as it is known not
4 ; to overflow. However (p + q) can, thus checks are needed.
6 ; CHECK: Invalid Context:
7 ; CHECK-NEXT: [r1, r2, q, p] -> { : r2 > r1 and (p <= -2147483649 - q or r2 >= 128 + r1 or p >= 2147483648 - q) }
9 ; void wraps(int *A, int p, short q, char r1, char r2) {
10 ; for (char i = r1; i < r2; i++)
11 ; A[p + q] = A[(int)r1 + (int)r2];
14 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
16 define void @wraps(ptr %A, i32 %p, i16 signext %q, i8 signext %r1, i8 signext %r2) {
20 for.cond: ; preds = %for.inc, %entry
21 %i.0 = phi i8 [ %r1, %entry ], [ %inc, %for.inc ]
22 %cmp = icmp slt i8 %i.0, %r2
23 br i1 %cmp, label %for.body, label %for.end
25 for.body: ; preds = %for.cond
26 %conv3 = sext i8 %r1 to i64
27 %conv4 = sext i8 %r2 to i64
28 %add = add nsw i64 %conv3, %conv4
29 %arrayidx = getelementptr inbounds i32, ptr %A, i64 %add
30 %tmp = load i32, ptr %arrayidx, align 4
31 %conv5 = sext i16 %q to i32
32 %add6 = add nsw i32 %conv5, %p
33 %idxprom7 = sext i32 %add6 to i64
34 %arrayidx8 = getelementptr inbounds i32, ptr %A, i64 %idxprom7
35 store i32 %tmp, ptr %arrayidx8, align 4
38 for.inc: ; preds = %for.body
42 for.end: ; preds = %for.cond