1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s 2; 3; void f(int *A, char N, char p) { 4; for (char i = 0; i < N; i++) { 5; A[i + 3] = 0; 6; } 7; } 8; 9; The wrap function has no inbounds GEP but the nowrap function has. Therefore, 10; we will add the assumption that i+1 won't overflow only to the former. 11; 12; CHECK: Function: wrap 13; CHECK: Invalid Context: 14; CHECK: [N] -> { : N >= 126 } 15; 16; 17; FIXME: This is a negative test as nowrap should not need an assumed context. 18; However %tmp5 in @nowrap is translated to the SCEV <3,+,1><nw><%bb2> 19; which lacks the <nsw> flags we would need to avoid runtime checks. 20; 21; CHECK: Function: nowrap 22; CHECK: Invalid Context: 23; CHECK-NOT: [N] -> { : } 24; 25target datalayout = "e-m:e-i8:64-f80:128-n8:16:32:64-S128" 26 27define void @wrap(i32* %A, i8 %N, i8 %p) { 28bb: 29 br label %bb2 30 31bb2: ; preds = %bb7, %bb 32 %indvars.iv = phi i8 [ %indvars.iv.next, %bb7 ], [ 0, %bb ] 33 %tmp3 = icmp slt i8 %indvars.iv, %N 34 br i1 %tmp3, label %bb4, label %bb8 35 36bb4: ; preds = %bb2 37 %tmp5 = add i8 %indvars.iv, 3 38 %tmp6 = getelementptr i32, i32* %A, i8 %tmp5 39 store i32 0, i32* %tmp6, align 4 40 br label %bb7 41 42bb7: ; preds = %bb4 43 %indvars.iv.next = add nsw nuw i8 %indvars.iv, 1 44 br label %bb2 45 46bb8: ; preds = %bb2 47 ret void 48} 49 50define void @nowrap(i32* %A, i8 %N, i8 %p) { 51bb: 52 br label %bb2 53 54bb2: ; preds = %bb7, %bb 55 %indvars.iv = phi i8 [ %indvars.iv.next, %bb7 ], [ 0, %bb ] 56 %tmp3 = icmp slt i8 %indvars.iv, %N 57 br i1 %tmp3, label %bb4, label %bb8 58 59bb4: ; preds = %bb2 60 %tmp5 = add nsw nuw i8 %indvars.iv, 3 61 %tmp6 = getelementptr inbounds i32, i32* %A, i8 %tmp5 62 store i32 0, i32* %tmp6, align 4 63 br label %bb7 64 65bb7: ; preds = %bb4 66 %indvars.iv.next = add nsw nuw i8 %indvars.iv, 1 67 br label %bb2 68 69bb8: ; preds = %bb2 70 ret void 71} 72